tomcat 9 配置了error page 状态码404起作用,状态400不起作用
可以自己通过代码来判断
该回答引用NewBing
您好!Tomcat 9 配置 error page 状态码 404 起作用,状态码 400 不起作用的问题,可能是由于您的 web.xml 文件中没有配置错误页面导致的。您可以在 web.xml 文件中添加以下代码来配置错误页面:
<error-page>
<error-code>400</error-code>
<location>/error/400.html</location>
</error-page>
其中,<error-code>
标签中填写状态码,<location>
标签中填写错误页面的路径。
如果您已经配置了错误页面,但是状态码 400 仍然不起作用,可能是由于 Tomcat 的 bug 导致的。您可以尝试升级 Tomcat 版本或者使用其他方式来解决这个问题(1)。
源: 与必应的对话, 2023/4/21
(1) Tomcat--配置400/404/500自定义错误页面_tomcat400错误页面不显示_吾日三省贾斯汀的博客-CSDN博客. https://blog.csdn.net/JustinQin/article/details/78879185.
(2) Why is this URL returning error 400 from Tomcat?. https://stackoverflow.com/questions/36220740/why-is-this-url-returning-error-400-from-tomcat.
(3) Custom error pages on Apache Tomcat - Server Fault. https://serverfault.com/questions/254102/custom-error-pages-on-apache-tomcat.