新的 Servlet 3.0 全局错误页面功能在 Tomcat 7 上不起作用
Servlet 3.0 规范规定可以在 web.xml
中列出全局错误消息以包含所有服务器错误。
示例:
<error-page>
<location>/error.jsp</location>
</error-page>
旧方法:
<error-page>
<error-code>401</error-code>
<location>/error.jsp</location>
</error-page>
当将此新方法添加到 Tomcat 7 中的 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.
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. How is this caused and how can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将是 Tomcat 7 中的一个错误。例如,它在 Glassfish 3 上运行良好。
是时候向 Tomcat 人员报告错误了,所以我这样做了:问题 52135。
更新:它已被关闭,因为 Servlet 规范“不清楚”
和
成为可选的。这仅在 Servlet 3.0 规范 的图 14-10 中显示,文本中没有字面意思,尽管新的 Servlet 3.0 XSD 确认了这一变化。后来这个问题被重新打开,并发布了一篇不错的博客文章的链接,再次证实了这一点。现在我们只能等待Tomcat开发人员真正修复它了。据我所知,根据 Tomcat 源代码,这将不是一个简单的修复,这也许就是它这么快被关闭的原因。更新2:这个问题终于在Tomcat 7.0.29中得到修复和实现。
That'll be a bug in Tomcat 7. It works fine on Glassfish 3, for example.
It's time to report a bug to Tomcat guys, so I did: issue 52135.
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.Update 2: this has finally been fixed and implemented in Tomcat 7.0.29.