【问题标题】:How to change handling of internal server error?如何更改内部服务器错误的处理?
【发布时间】:2015-11-19 10:00:30
【问题描述】:

我的应用程序产生了一个内部服务器错误,在 tomcat 上运行它会打印一个带有给定错误的堆栈跟踪。在 Oracle 上,它会隐藏错误并将其发布到 application.log

是否可以通过部署描述符更改此设置?

500 Internal Server Error

Servlet error: An exception occurred. The current application deployment
descriptors do not allow for including it in this response. 

Please consult the application log for details.

【问题讨论】:

  • 您使用的是哪个 Web 服务器和/或 Web 容器(或应用程序服务器)?

标签: java web-applications error-handling oas


【解决方案1】:

您可以在 web.xml 中定义错误处理页面:

<error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/pages/500.jsp</location>
</error-page>

如果您的应用程序明确设置了错误代码,请确保它使用response.sendError() 而不是response.setStatus(),因为后者将忽略您在 web.xml 中定义的自定义错误页面

p.s 通过谷歌搜索您的错误消息,我假设这是一个在 OAS 上运行的 Java Web 应用程序

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    • 2018-07-08
    相关资源
    最近更新 更多