springboot内置tomcat报错:Invalid character found in the request target. The valid characters are defined

@SpringBootApplication
@EnableEurekaClient
public class StartUpMain {

    public static void main(String[] args) {
        SpringApplication.run( StartUpMain.class, args );
    }

    @Bean
    public TomcatServletWebServerFactory tomcatServletWebServerFactory (){
        // 修改内置的 tomcat 容器配置
        TomcatServletWebServerFactory tomcatServlet = new TomcatServletWebServerFactory();
        tomcatServlet .addConnectorCustomizers(
                (TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "[]{}")
        );
        return tomcatServlet ;
    }



}

将Bean这块代码加入启动项就可以了,网上介绍说是tomcat高版本的请求不支持特殊字符,这里在启动项中将字符进行下设置

你可能感兴趣的:(springboot内置tomcat报错:Invalid character found in the request target. The valid characters are defined)