当我想转发到不存在的资源时,我想让调度程序抛出异常,这是我的代码
String page = (String) request.getAttribute("page"); //page to be forwarded form servlet to jsp
if (page == null) {
page = request.getParameter("page");//page to be forwarded form jsp to servlet
}
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/InstitutionPages/" + page + ".jsp");
try {
dispatcher.forward(request, response);
} catch (IOException ex) {
ex.printStackTrace();
LogoutServlet.redirectToLoginPage(request, response);
} catch (javax.servlet.ServletException e) {
e.printStackTrace();
Logger.getLogger(RegistrarManagementServlet.class.getName()).log(Level.SEVERE, null, e);
LogoutServlet.redirectToLoginPage(request, response);
} catch (java.lang.IllegalArgumentException e) {
e.printStackTrace();
LogoutServlet.redirectToLoginPage(request, response);
}
在页面中,我发送无效的页面名称,但在控制台上发生此错误
SEVERE: PWC6117: File "D:\versions\v30\OnlineQuerySystem_New\build\web\WEB-INF\InstitutionPages\Registerkk.jsp" not found
没有打印任何堆栈跟踪!