public void doError(HttpServletRequest request, HttpServletResponse response, String str)
throws ServletException, IOException {
request.setAttribute("problem", str);
getServletConfig().getServletContext().getRequestDispatcher("/errorpage.jsp"); // 缺 forward
}
現象:驗證失敗時,頁面不跳轉,錯誤信息不顯示。
public void doError(HttpServletRequest request, HttpServletResponse response, String str)
throws ServletException, IOException {
request.setAttribute("problem", str);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/errorpage.jsp");
rd.forward(request, response); // 必須 forward
}