方法一:降低Tomcat 的版本
方法二:修改Tomcat 的配置文件。
server.xml 添加 relaxedPathChars,relaxedQueryChars
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
URIEncoding="utf-8" relaxedPathChars="|{}[],%"
relaxedQueryChars="|{}[],%"
/>
方法三:修改后端适配,Spring boot 添加一个配置项。
@Configuration
public class TomcatConfig {
@Bean
public TomcatServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers((Connector connector) -> {
connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
});
return factory;
}
}
方法四:修改前端, 设置axios对数组的处理方式。
const http = axios.create({
paramsSerializer : params => {
return qs.stringify(params, {arrayFormat: 'brackets'});
}
});