我尝试使用error-page元素在web.xml中配置错误页面,但是从不显示错误页面,而是以原始形式向查看应用程序的用户抛出异常。
我该怎么办?我没有找到任何线索,为什么会这样。任何帮助都非常感谢。
此致 阿西
答案 0 :(得分:4)
您可以为Exception
添加错误页面,如下所示
<error-page>
<error-code>400</error-code>
<location>/400.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
<error-page>
<exception-type>your.company.YourException</exception-type>
<location>/errorPage.html</location>
</error-page>
如果要在所有类型的例外上显示错误页面,请重新检查Exception
类型,然后使用java.lang.Exception