-
为页面指定异常处理方式。
01.如果出现错误指向500.jsp
02.500.jsp
-
通过web.xml配置。
全局的错误处理可以处理两种类型的错误:一种是HTTP代码的错误,如404,500;
另一种是异常的错误,如NullPointerException.
<error-page>
<error-code>500</error-code>
<location>目录/error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>目录/notfount.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/目录/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception </exception-type>
<location>/目录/exception.jsp</location>
</error-page>