Strus2.5更新用户成功后视图自动跳转不成功

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() 


小冥王
浏览 1138回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java