简体   繁体   English

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

[英]Error Page configuration in web.xml for JSF application

I have tried to configure error page in web.xml using error-page element, but the error page is never shown rather the exceptions are thrown out in raw form to the user viewing the application. 我曾尝试使用error-page元素在web.xml中配置错误页面,但从未显示错误页面,而是以原始形式向查看应用程序的用户抛出了异常。

What should I do about it? 我该怎么办? I have not found any clue as to why is this so. 对于为什么会这样,我还没有发现任何线索。 Any help is highly thankful. 任何帮助都非常感谢。

Regards, Asif 问候,Asif

You can add error pages for Exception as follows 您可以按如下所示为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>

Recheck the Exception type if you want to show error page on all type of exception then use java.lang.Exception 如果要在所有类型的异常上显示错误页面,请重新检查Exception类型,然后使用java.lang.Exception

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM