Non-ASCII symbols in path variable of Spring MVC application on embedded Tomcat server setup using Spring Boot

后端 未结 1 1780
悲哀的现实
悲哀的现实 2021-01-23 02:14

I am building a service using Spring MVC set up using Spring Boot where I want to be able to have arbitrary unicode characters in the URLs.

By looking around the web I e

1条回答
  •  心在旅途
    2021-01-23 02:34

    Following the event of a brain-wave, adding the bean method

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {
        TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(8080);
        factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
    
            @Override
            public void customize(Connector connector) {
                connector.setURIEncoding("UTF-8");
            }
        });
        return factory;
    }
    

    seems to solve the problem.

    Edit

    The CharacterEncodingFilter is still necessary for converting POST bodies.

    0 讨论(0)
提交回复
热议问题