Setting 'relaxedQueryChars' for embedded Tomcat

后端 未结 3 2103
既然无缘
既然无缘 2021-01-17 13:43

How can I set relaxedQueryChars for Spring Boot embedded Tomcat?

The connector attribute described here, but Spring Boot documentation has no such param

3条回答
  •  天涯浪人
    2021-01-17 14:36

    If you are using Spring Boot 2.x then you need to use WebSeerverFactoryCustomizer as given below.

    @Bean
    public WebServerFactoryCustomizer 
        containerCustomizer(){
        return new EmbeddedTomcatCustomizer();
    }
    
    private static class EmbeddedTomcatCustomizer implements WebServerFactoryCustomizer {
    
        @Override
        public void customize(TomcatServletWebServerFactory factory) {
            factory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
                connector.setAttribute("relaxedPathChars", "<>[\\]^`{|}");
                connector.setAttribute("relaxedQueryChars", "<>[\\]^`{|}");
            });
        }
    }
    

提交回复
热议问题