public class ApplicationException extends RuntimeException { public ApplicationException() { } public ApplicationException(String message) { super(message); } public ApplicationException(Throwable cause) { super(cause); } public ApplicationException(String message, Throwable cause) { super(message, cause); } public ApplicationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } }
<!-- 错误跳转页面的配置 --> <error-page> <exception-type>com.bjpowernode.drp.util.ApplicationException</exception-type> <location>/error.jsp</location> </error-page>
<div align="center"><p align="left"><span class="STYLE1">错误信息:</div> <div><%=exception.getMessage()%></div>
<!-- 错误跳转页面的配置 --> <error-page> <error-code>404</error-code> <location>/http_error.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/http_error.jsp</location> </error-page>
<body> <% Integer errorCode=(Integer)request.getAttribute("javax.servlet.error.status_code"); //当分别遇到错误码为404和500时,分别跳转到相应的错误处理页面进行处理 if (errorCode==404){ response.sendRedirect(request.getContextPath()+ "/404.jsp"); }else if (errorCode==500){ response.sendRedirect(request.getContextPath()+ "/500.jsp"); } %> </body>
3)错误处理页面处理如果是404:<body> 未找到请求的页面</body>如果是500:<body>系统出现错误,请与系统管理员联系!</body>
原文地址:http://blog.csdn.net/u010927139/article/details/46558313