各位大大,小弟正在用java做毕业设计,遇到一个问题,就是想实现获取页面的学生姓名sname和学号sno,然后到数据库中执行查询,将这个学生的成绩从数据库中输出到新的页面。可是,问题来了:在查询页面点击提交按钮后,页面跳转到ChengjiServlet2页面,web浏览器就一片空白,在ChengjiServlet2页面的sendRedirect也没了作用。。。希望各位大大们看在我操心做毕业设计的份儿上帮帮我吧,说白了就是一个查询输出,望大大们指点!跪谢!!
//查询页面,jsp。放在一个文件夹里。路径没出错//这是我编写的ChengjiServlet2类
<body>
<form id="form1" name="chengjiFrom" method="post" action="../ChengjiServlet2"><h1 align="center">成绩查询页面</h1>
<p>姓名:
<input name="sname" type="text" id="sname" />
</p>
<p>学号:
<input name="sno" type="text" id="sno" />
</p>
<p>
<input type="submit" name="Submit" value="查询成绩" />
</p>
</form>
</body>
[code=java]
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List chengji = new ArrayList();
//获取chengjichaxun.jsp页面的各个控件属性
String Sname = request.getParameter("sname");
String Sno = request.getParameter("sno");
String SelectScore = request.getParameter("select");
ChengjiSQLUtil chengjiSql = new ChengjiSQLUtil();
Connection conn =null;
Statement stmt=null;
ResultSet rs = null;
conn = chengjiSql.getConn_Bendi();
try
{
if(SelectScore.equals("score_1"))
{
//创建Statement实例,并执行sql语句
String sql = "SELECT * FROM 'renwu'.'score_da1' where sno='"+Sno+"' and sname='"+Sname+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
String sno = rs.getString("sno");
String sname = rs.getString("sname");
String ke1_a = rs.getString("ke1_a");
String ke1_b = rs.getString("ke1_b");
String ke1_c = rs.getString("ke1_c");
String ke1_d = rs.getString("ke1_d");
String ke1_e = rs.getString("ke1_e");
String ke1_f = rs.getString("ke1_f");
chengji.add(sno);
chengji.add(sname);
chengji.add(ke1_a);
chengji.add(ke1_b);
chengji.add(ke1_c);
chengji.add(ke1_d);
chengji.add(ke1_e);
chengji.add(ke1_f);
}
HttpSession session = request.getSession();
session.setAttribute("score", chengji);
response.sendRedirect("chaxun_chengji/chengji_jieguo.jsp");
}
else if(SelectScore.equals("score_2"))
{
String sql = "SELECT * FROM 'renwu'.'score_da2' where sno='"+Sno+"' and sname='"+Sname+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
String sno = rs.getString("sno");
String sname = rs.getString("sname");
String ke2_a = rs.getString("ke2_a");
String ke2_b = rs.getString("ke2_b");
String ke2_c = rs.getString("ke2_c");
String ke2_d = rs.getString("ke2_d");
String ke2_e = rs.getString("ke2_e");
String ke2_f = rs.getString("ke2_f");
chengji.add(sno);
chengji.add(sname);
chengji.add(ke2_a);
chengji.add(ke2_b);
chengji.add(ke2_c);
chengji.add(ke2_d);
chengji.add(ke2_e);
chengji.add(ke2_f);
}
HttpSession session = request.getSession();
session.setAttribute("score", chengji);
response.sendRedirect("chaxun_chengji/chengji_jieguo.jsp");
}
else if(SelectScore.equals("score_3"))
{
String sql = "SELECT * FROM 'renwu'.'score_da3' where sno='"+Sno+"' and sname='"+Sname+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
String sno = rs.getString("sno");
String sname = rs.getString("sname");
String ke3_a = rs.getString("ke3_a");
String ke3_b = rs.getString("ke3_b");
String ke3_c = rs.getString("ke3_c");
String ke3_d = rs.getString("ke3_d");
String ke3_e = rs.getString("ke3_e");
String ke3_f = rs.getString("ke3_f");
chengji.add(sno);
chengji.add(sname);
chengji.add(ke3_a);
chengji.add(ke3_b);
chengji.add(ke3_c);
chengji.add(ke3_d);
chengji.add(ke3_e);
chengji.add(ke3_f);
}
HttpSession session = request.getSession();
session.setAttribute("score", chengji);
response.sendRedirect("chaxun_chengji/chengji_jieguo.jsp");
}
else if(SelectScore.equals("score_4"))
{
String sql = "SELECT * FROM 'renwu'.'score_da4' where sno='"+Sno+"' and sname='"+Sname+"'";