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 自动生成的 catch 块 e.printStackTrace(); } return "update"; }
异常显示:Cannot call sendRedirect() after the response has been committed 响应后提交不能调用sendRedirect()
相关分类