如何捕获 FacesFileNotFoundException?
我怎样才能抓住一个
com.sun.faces.context.FacesFileNotFoundException
Java EE Web 应用程序中的
?我尝试在 web.xml 文件中添加以下几行,但没有成功:
...
<error-page>
<error-code>404</error-code>
<location>/404.jsf</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/404.jsf</location>
</error-page>
<error-page>
<exception-type>FacesFileNotFoundException</exception-type>
<location>/404.jsf</location>
</error-page>
<error-page>
<exception-type>FileNotFoundException</exception-type>
<location>/404.jsf</location>
</error-page>
<error-page>
<exception-type>FailingHttpStatusCodeException</exception-type>
<location>/404.jsf</location>
</error-page>
</web-app>
How can I catch a
com.sun.faces.context.FacesFileNotFoundException
in a Java EE web application?
I tried it with adding the following lines in my web.xml file but I was not successful:
...
<error-page>
<error-code>404</error-code>
<location>/404.jsf</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/404.jsf</location>
</error-page>
<error-page>
<exception-type>FacesFileNotFoundException</exception-type>
<location>/404.jsf</location>
</error-page>
<error-page>
<exception-type>FileNotFoundException</exception-type>
<location>/404.jsf</location>
</error-page>
<error-page>
<exception-type>FailingHttpStatusCodeException</exception-type>
<location>/404.jsf</location>
</error-page>
</web-app>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要指定 FQN(完整限定名称),而不仅仅是 N 作为异常类型。
或者,如果您已经使用 OmniFaces,请注册其
FacesExceptionFilter
,然后FacesFileNotFoundException
将被处理为 404。You need to specify the FQN (Full Qualified Name), not just the N as exception type.
Alternatively, if you already happen to use OmniFaces, register its
FacesExceptionFilter
and then theFacesFileNotFoundException
will be handled as 404.