tomcat特殊字符处理问题解决方案
- 直接加上如下代码,本质是通过反射加上过滤字符
@Configuration
public class TomcatConfig {
@Bean
public ConfigurableServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
//允许的特殊字符
connector.setProperty("relaxedQueryChars", "|{}[]");
});
return factory;
}
}