用于JSF应用程序的web.xml中的错误页面配置

时间:2011-05-15 21:04:31

标签: jsf config web.xml

我尝试使用error-page元素在web.xml中配置错误页面,但是从不显示错误页面,而是以原始形式向查看应用程序的用户抛出异常。

我该怎么办?我没有找到任何线索,为什么会这样。任何帮助都非常感谢。

此致 阿西

1 个答案:

答案 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