这是doPost中的代码:
try {
switch (request.getParameter("action")){
case "delete":
request.setAttribute("message", "Deleting...");
break;
case "update":
request.setAttribute("message", "Updating...");
break;
case "new":
response.sendRedirect("createNew.jsp");
break;
default:
super.doPost(request, response);
break;
}
} finally {
request.getRequestDispatcher("backHome.jsp").forward(request, response);
out.close();
}
问题是最终我在案例为'new'时遇到此异常: java.lang.IllegalStateException:
答案 0 :(得分:1)
如果是" new"你在做response.sendRedirect("createNew.jsp");
。此时写入响应流。
最后你正在做request.getRequestDispatcher("backHome.jsp").forward(request, response);
。它转发到另一个网址。
java.lang.IllegalStateException
。