赞
踩
Note: further occurrences of HTTP request parsing errors will be
logged at DEBUG level.java.lang.IllegalArgumentException: Invalid character found in the
request target. The valid characters are defined in RFC 7230 and RFC
3986
一、在发送请求头参数给后端的时候会出现上述异常,这是由于tomcat配置引起,在SpringBoot项目中添加如下配置类即可。
/**
* @author 码不多
* @version 1.0
* @description: 解决java.lang.IllegalArgumentException:Invalid character found in the request 异常
* @date 2022/1/9 20:54
*/
@Configuration
public class TomCatConfig {
@Bean
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers((Connector connector) -> {
connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
});
return factory;
}
}
二、当请求头的参数过长时会出现 :
Note: further occurrences of HTTP request parsing errors will be
logged at DEBUG level.java.lang.IllegalArgumentException: Request header is too larg
上述异常解决办法 : 修改application.properties或yaml配置文件添加 :
server.max-http-header-size=102400
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。