如何在web.xml中指定常见错误页面,不包括404和500

时间:2017-11-16 06:37:02

标签: java error-handling web.xml


我已经有两个网页设计用于web.xml中的404和500个错误页面

 <error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/error/404.jsp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/WEB-INF/error/500.jsp</location>
    </error-page>

我想将所有其他错误重定向到预先指定的页面。
请帮忙。 谢谢

1 个答案:

答案 0 :(得分:0)

这应该足够了,与少数客户错误相关的页面,您可以添加默认页面。因此, 404 500 以外的所有错误都将重定向到通用页面ShopSupplier

error.html

或更多自定义,使用异常类,也可以是您的自定义异常类。

<error-page>
    <location>/error.html</location>
</error-page>

所以代码变成,

<error-page>
  <exception-type>java.lang.Throwable</exception-type>
  <location>/error.html</location>
</error-page>
相关问题