新的Servlet 3.0全局错误页面功能在Tomcat 7上不起作用 [英] New Servlet 3.0 global error page feature does not work on Tomcat 7

查看:138
本文介绍了新的Servlet 3.0全局错误页面功能在Tomcat 7上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Servlet 3.0规范规定,全局错误消息可以在 web.xml 中列出,以包含所有服务器错误。

The Servlet 3.0 specification states that a global error message can be listed in the web.xml to encompass all server errors.

示例:

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

旧方法:

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

将此新方法添加到我的 web.xml 在Tomcat 7中,它不起作用。这是如何引起的,我该如何解决?

When adding this new method to my web.xml in Tomcat 7, it does not work. How is this caused and how can I solve it?

推荐答案

这将是Tomcat 7中的一个错误。 Glassfish 3,例如。

That'll be a bug in Tomcat 7. It works fine on Glassfish 3, for example.

现在是向Tomcat的人报告错误的时候了,所以我做了: issue 52135

It's time to report a bug to Tomcat guys, so I did: issue 52135.

更新:它已被关闭,因为Servlet规范不清楚,< exception-type> < error-code> 成为可选项。这仅显示在 Servlet 3.0规范的图14-10中,文字无法显示即使新的Servlet 3.0 XSD证实了这一变化。后来被重新打开,并且发布了一个不错的博客文章的链接,这再一次证明了这一点。现在我们只需要等待Tomcat开发人员来修复它。基于Tomcat源代码,我可以看到,这不是一个微不足道的修复,也许是为什么它很快关闭。

Update: it has been closed because the Servlet spec was "not clear" that <exception-type> and <error-code> became optional. 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. 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. 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.

更新2 :最终在Tomcat 7.0.29中修复并实现。

Update 2: this has finally been fixed and implemented in Tomcat 7.0.29.

这篇关于新的Servlet 3.0全局错误页面功能在Tomcat 7上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆