简体   繁体   English

新的Servlet 3.0全局错误页面功能在Tomcat 7上不起作用

[英]New Servlet 3.0 global error page feature does not work on Tomcat 7

The Servlet 3.0 specification states that a global error message can be listed in the web.xml to encompass all server errors. Servlet 3.0规范声明可以在web.xml列出全局错误消息以包含所有服务器错误。

Example: 例:

<error-page>
    <location>/error.jsp</location>
</error-page>

Old Method: 旧方法:

<error-page>
    <error-code>401</error-code>
    <location>/error.jsp</location>
</error-page>

When adding this new method to my web.xml in Tomcat 7, it does not work. 将此新方法添加到Tomcat 7中的web.xml时,它不起作用。 How is this caused and how can I solve it? 这是怎么造成的,我该如何解决?

That'll be a bug in Tomcat 7. It works fine on Glassfish 3, for example. 这将是Tomcat 7中的一个错误。例如,它可以在Glassfish 3上正常工作。

It's time to report a bug to Tomcat guys, so I did: issue 52135 . 现在是时候向Tomcat报告一个bug了,所以我做了: 发行52135


Update : it has been closed because the Servlet spec was "not clear" that <exception-type> and <error-code> became optional. 更新 :它已关闭,因为Servlet规范“不清楚” <exception-type><error-code>成为可选项。 This was only shown in figure 14-10 of the Servlet 3.0 spec and nowhere literally in the text, even though the new Servlet 3.0 XSD confirms this change. 这只是在Servlet 3.0规范的图14-10中显示,并且文本中没有字面,即使新的Servlet 3.0 XSD确认了这一变化。 This was later been reopened and a link to a nice blog article was posted which confirms this only once more. 这是后来重新打开的,并发布了一篇很好的博客文章的链接,这再次证实了这一点。 Now we have only to wait for the Tomcat developers to really fix it. 现在我们只需要等待Tomcat开发人员真正解决它。 Based on the Tomcat source code as far as I can see, it's not going to be a trivial fix and that was perhaps why it was closed so soon. 根据我所看到的Tomcat源代码,它不会是一个微不足道的修复,这也许就是为什么它很快就关闭了。


Update 2 : this has finally been fixed and implemented in Tomcat 7.0.29. 更新2 :最终修复并在Tomcat 7.0.29中实现。

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

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