Tomcat is not redirecting to 400 bad request custom error page

六月ゝ 毕业季﹏ 提交于 2019-12-05 17:25:17

This is not a bug, it is a configuration issue.

Tomcat 9 has improved the error handling so that more errors, particularly those those occur before request processing starts, are passed to the standard error handling mechanism rather than just returning an error code.

In the case of malformed URIs, it is not possible for Tomcat to parse the URI hence the URI cannot be mapped to a web application. Tomcat is, therefore, unable to trigger the application level error handling because it cannot identify an application. In this case, the error is handled by the ErrorReportValve which can be configured in server.xml.

A recent(ish) addition to the ErrorReportValve is the ability to define static web pages (i.e. no Servlets or JSPs, just HTML) per status code and/or Exception type in a similar manner to the per web application error page configuration.

You can write your own error page https://aspiresoftware.in/blog/catalinatomcat-custom-error-report-valve-to-handle-errors-exceptions/

You have to put your jar in tomcat lib.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!