gpt4 book ai didi

tomcat - 在 Tomcat 中抑制 500 错误堆栈跟踪

转载 作者:行者123 更新时间:2023-11-28 23:20:54 25 4
gpt4 key购买 nike

当发生 500 个内部服务器时,我想抑制 tomcat 显示的堆栈跟踪。我包含了一个自定义的 error.html 页面,并在 web.xml 中提到了文件位置和错误代码。

<error-page>
<error-code>500</error-code>
<location>/error.html</location>
</error-page>

进行上述更改后,对于所有 API 的 tomcat 都返回 404 Not Found。

最佳答案

web.xml 中,添加如下内容:

<error-page>
<error-code>400</error-code>
<location>/WEB-INF/jsp/errorpages/ErrorPage400.jsp</location>
</error-page>
<error-page>
<error-code>401</error-code>
<location>/WEB-INF/jsp/errorpages/ErrorPage401.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/jsp/errorpages/ErrorPage403.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/errorpages/ErrorPage404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/html/error.html</location>
</error-page>



HTML文件的路径应该是/WEB-INF/html/error.html

关于tomcat - 在 Tomcat 中抑制 500 错误堆栈跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43981253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com