tomcat9以前版本存在缺陷,在web.xml配置400页面不生效,tomcat9以后优化了此缺陷,以下是解决方案。
第一步:修改tomcat目录下/conf/server.xml
Host节点增加配置
<Valve className="org.apache.catalina.valves.ErrorReportValve" errorCode.400="webapps/ROOT/400.html"
showReport="false" showServerInfo="false" />
第二步:在webapps目录下新建文件夹ROOT,添加400.html
第三步:重启tomcat
本文参考:https://qa.1r1g.com/sf/ask/3697020771/