步骤:直接在web.xml中配置如下代码
对于服务器内部的500异常,如果有按异常类型配置错误页面,则优先按类型展示,没有找到对应类型页面才展示错误码为500的页面,如果没找到 ,则打印堆栈在页面上
<!-- 需要访问的资源不存在 -->
<error-page>
<error-code>404</error-code>
<location>/pages/404.jsp</location>
</error-page>
<!-- 出现异常 -->
<error-page>
<error-code>500</error-code>
<location>/pages/500.jsp</location>
</error-page>
<error-page>
按类型展示的页面
<exception-type>java.lang.RuntimeException</exception-type>
<location>/pages/runtimeex.jsp</location>
</error-page>