How to solve tomcat exception error:
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
Tomcat has made relatively standardized restrictions on URL parameters since tomcat 8.0.35, and must follow the RFC 7230 and RFC 3986 standard.
If the requested url contains non-standard characters such as ‘{‘ ‘,|’, ‘<‘, ‘>’, etc,tomcat will occur this error.
1, modify the requester(recommend)
Urlencode the requested Url parameter.
2,Modify the tomcat configuration on the server side
Sometimes the request side cannot be modified, so start from the server side.
- find catalina.properties from the tomcat installation directory /conf, and modify the last two lines of the configuration:
tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
This method can only solve the situation where the Url contains’|”,'(‘,’)’
- find server.xml file from the tomcat installation directory /conf,and in the Connector node of XML, add the relaxedQueryChars attribute:
<Connector executor="threadPool" relaxedQueryChars="[]|{}^\`"<>"