postman发送请求时带jsonarry类型的情况时,需要在springboot的启动类上加上方法。
/**
* 特殊字符的请求报400错误处理
* @return
*/
@Bean
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
}
});
return factory;
}
或者在配置文件中:加上
(https://img-blog.csdnimg.cn/7732ad21b04d4d66b776cf412c135300.png)
tomcat:
relaxed-path-chars: "[,],{,}"
亲测有效
仅作参考,有错误,希望指出~