【发布时间】:2013-05-24 12:55:12
【问题描述】:
我使用的是 Apache MyFaces,需要以不同于其他内部服务器错误的方式处理 ViewExpiredException。但我发现如果我包含错误代码,则为 500;然后在 ViewExpiredException 错误中也采用错误代码的路径。
下面是web.xml配置:
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/login.xhtml?faces-redirect=true</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.xhtml</location>
</error-page>
对于上述两种情况,如何确保我可以重定向到不同的 URL? 参考multiple error-code configuration web.xml,我可以用单个 servlet 替换该位置;但是如何捕获 servlet 中的错误呢?
【问题讨论】: