input.jsp中通过表单跳转到servlet,servlet中doGet函数里通过分支语句if分别跳转,如果条件成立,跳到另一个servlet,(这个可以正常跳转)否则,跳转到input.jsp,可是它说找不到??
input.jsp如下:
<body>
<form action="insert_2" method="post">
<table>
<tr><td>学号:</td><td><input type="text" name="xh"></td></tr>
<tr><td>姓名:</td><td><input type="text" name="xm"></td></tr>
<tr><td>成绩:</td><td><input type="text" name="cj"></td></tr>
<tr><td>结束:</td><td><input type="radio" value="yes" name="xz">是
<input type="radio" value="no" name="xz" checked="checked">否</td></tr>
<tr><td colspan="2"><input type="submit" value="提交"></td></tr>
</table>
</form>
</body>
servlet如下:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String xh = request.getParameter("xh");
String xm = request.getParameter("xm");
double cj = Double.parseDouble(request.getParameter("cj"));
String xz = request.getParameter("xz");
St one = new St(xh, xm, cj);
List<St> list = new ArrayList<St>();
list.add(one);
if(!xz.equals("no")) {
request.setAttribute("aaa", list);
RequestDispatcher rd = request.getRequestDispatcher("insert_22");
rd.forward(request, response);
System.out.println(xz+"结束");
}
else {
RequestDispatcher rd = request.getRequestDispatcher("input_insetr1.jsp");
rd.forward(request, response);
System.out.println(xz+"继续");
}
}
错误结果