本文介绍了自定义500错误页面不适用于JBoss AS 7.1.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JBoss AS 7.1.1上部署了JAX-RS应用程序.在web.xml文件中,我配置了自定义错误页面:

I have a JAX-RS application deployed on JBoss AS 7.1.1.In the web.xml file I configured custom error pages:

<error-page>
  <error-code>404</error-code>
  <location>/error.jsp</location>
</error-page>
<error-page>
  <error-code>500</error-code>
  <location>/error.jsp</location>
</error-page>

对于404(未找到)错误,它可以正常工作.但是,对于500(内部服务器错误),它无法按预期工作:

It's working ok for 404 (no found) errors.However, for 500 (internal server error), it doesn't work as expected:

  • 如果我的方法抛出异常,那么将显示我的自定义错误页面
  • 但是,如果我在方法中使用返回Response.serverError.build()返回Response.status(500).build(),则显示默认的JBoss错误页面,而不是我的自定义页面!
  • if my method throws an Exception, then my custom error page is displayed
  • however, if I use in my method return Response.serverError.build()or return Response.status(500).build() then the default JBoss error page is displayed instead of my custom one!

我该如何解决?谢谢您的回答.

How can I fix this?Thank you for your answers.

推荐答案

ExceptionMapper impl类捕获异常,而不是让自定义错误页面从web.xml中解决

ExceptionMapper impl class catches the exception instead of letting the custom error page to be resolved from web.xml

解决方法是删除ExceptionMapper impl类.

The resolution would be to remove the ExceptionMapper impl class.

这篇关于自定义500错误页面不适用于JBoss AS 7.1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 09:09