Invalid character found in the request target.

背景:springboot项目内置tomcat9.0

调用的接口中有{}就会报错

解决办法:

新的tomcat新版本增加了一个新特性,就是严格按照 RFC 3986规范进行访问解析,而 RFC 3986规范定义了Url中只允许包含英文字母(a-zA-Z)、数字(0-9)、-_.~4个特殊字符以及所有保留字符(RFC3986中指定了以下字符为保留字符:! * ’ ( ) ; : @ & = + $ , / ? # [ ])。
由于请求中包含了特殊的保留字符,所以tomcat无法正确解析请求参数,导致出错。
解决方法:
1.降低tomcat的版本。
2.采用最新tomcat版本。对请求链接进行编码,并修改对应的过滤器,对所有请求链接进行编码解析处理。

参考资料:

1.tomcat升级后报错: Invalid character found in the request target.

2.java.lang.IllegalArgumentException: Invalid character found in the request target. The valid charact

原文地址:https://www.cnblogs.com/jycjy/p/10266477.html