我正在使用 JSF2 和 Glassfish 3.0。
我有一个非常简单的应用程序,我正在尝试设置一些默认错误页面404
and 500
error.
这是WEB.XML
部分:
<error-page>
<exception-type>404</exception-type>
<location>/error.xhtml</location>
</error-page>
<error-page>
<exception-type>500</exception-type>
<location>/error.xhtml</location>
</error-page>
即使 error.xhtml 存在,在浏览器中我仍然得到标准HTTP Status 404 -
警告。
The <exception-type>
应该指向子类的完整限定名称java.lang.Exception. E.g.
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/expired.xhtml</location>
</error-page>
但你所拥有的只是HTTP 状态代码。你应该使用<error-code>
反而。
<error-page>
<error-code>500</error-code>
<location>/error.xhtml</location>
</error-page>
顺便说一句,我不会让 404 和 500 指向同一个错误页面。 404 是“找不到页面”,通常是客户端自己的错误,而不是服务器的错误。获得一般错误页面而不是“找不到页面”将会非常令人困惑。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)