Hello! I recently update Spring Boot version to 2.6.6, and got 404 error when access resources which url contains Chinese.

There is no problem rolling back to 2.5.x or below.

My project structure :

SpringBoot 404 error when resources URL contains Chinese  since 2.6.x

Here is my code :

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.0</version>
</parent>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>
// DemoApp.java
@SpringBootApplication
public class DemoApp {

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

// MvcConfig.java
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/attach/**")
                .addResourceLocations("file:attach/");
    }
}

Code run with JDK 1.8 on windows 10 64bit.

URL result
http://localhost:8080/attach/%E5%BC%A0%E9%92%A7%E7%94%AF.png 🔴 404
http://localhost:8080/attach/张钧甯.png 🔴 404
http://localhost:8080/attach/zhangjunning.png

Thanks!

Comment From: bclozel

Closing as a duplicate of spring-projects/spring-framework#27791