public?String?updateStu(){
????????StudentService?ss?=?new?StudentServiceImpl();
????????int?id?=?Integer.parseInt(request.getParameter("id"));
????????Student?s?=?ss.getStudentById(id);?
????????request.setAttribute("stu",?s);????
????????try?{
????????????request.getRequestDispatcher("/jsps/PrepareUpdate.jsp").forward(request,?response);
????????}?catch?(ServletException?e)?{
????????????e.printStackTrace();
????????}?catch?(IOException?e)?{
????????????e.printStackTrace();
????????}
????????
????????String?name?=?request.getParameter("name");
????????int?age?=?Integer.parseInt(request.getParameter("age"));
????????Student?s1?=?new?Student(id,name,age);
????????ss.updateStudent(s1);
????????try?{
????????????response.sendRedirect("../getAll_stu.do");
????????????
????????}?catch?(IOException?e)?{
????????????//?TODO?自動(dòng)生成的?catch?塊
????????????e.printStackTrace();
????????}????????
????????return?"update";????????
????}異常顯示:Cannot call sendRedirect() after the response has been committed??? 響應(yīng)后提交不能調(diào)用sendRedirect()?
添加回答
舉報(bào)
0/150
提交
取消