<label>输入您要投票的教师工号:<input type="text" name="tId" id="name" onmouseout="helloPressed();"/><button dojoType="Button" widgetId="helloButton" onClick="helloPressed();">显示教师信息</button></label> js调用server.jsp页面 显示回来.. <script type="text/javascript" src="../dojojs/dojo.js"></script><script type="text/javascript"> dojo.require("dojo.widget.*");</script><script> function helloPressed() ...{ dojo.io.bind(...{ url: 'server.jsp', method:'POST', handler: helloCallback, content: ...{name: dojo.byId('tId').value } }); } function helloCallback(type, data, evt) ...{ if (type == 'error') ...{ alert('读取服务器数据时出错'); } else ...{ dojo.byId("show").innerHTML = data; } }</script> serve.jsp <%@page contentType="text/html;charset=GB2312"%><%@page import="java.sql.*,com.teacher.*,com.pool.*;" %><% request.setCharacterEncoding("GB2312");%><%!String r1="",r2="",r3="",r4="",r5="",r6="",r7=""; %><% String name=null,r7=new String(""); name=request.getParameter("name"); if(name.length()!=0&&!name.equals("")) ...{ Connection conn=null; Statement stmt=null; ResultSet rs=null; String sql="select * from teacher where tId="+name+";"; try...{ conn = ConnDB.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql); if(rs.next()) ...{ r1=rs.getString(1); r2=rs.getString(2); r3=rs.getString(3); r4=rs.getString(4); r5=rs.getString(5); r6=rs.getString(6); }else ...{ r7="没有这个老师!请查询清楚!"; } }catch(Exception ex) ...{ ex.printStackTrace(); } } if(r7.length()==0&&r7.equals("")) ...{%><table><tr><td><%=r1%></td><td><%=r2%></td><td><%=r3%></td><td><%=r4%></td><td><%=r5%></td><td><%=r6%></td></tr></table><table><% }else ...{%> <tr><td><%=r7 %></td></tr> <%} %></table>