在web.xml中有两种配置error-page的方法,一种是通过错误码来配置,二是通过异常的类型来配置,分别举例如下:

一、通过错误码来配置error-page
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
上面配置了当系统发生404错误时,跳转到错误处理页面error.jsp

二、通过异常的类型配置error-page
<error-page>
<exception-type>java.lang.NullPointException</exception-type>
<location>/error.jsp</location>
</error-page>
上面配置了当系统发生java.lang.NullPointException时,跳转到处理页面error.jsp

相关文章:

  • 2022-12-23
  • 2021-11-22
  • 2021-04-30
  • 2021-11-17
  • 2021-11-01
  • 2021-08-29
猜你喜欢
  • 2021-10-02
  • 2022-01-02
  • 2022-12-23
  • 2021-06-27
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案