Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 occurs when configuring access to local static files, which may be caused by URL transcoding #28381

Closed
Ziyear opened this issue Apr 26, 2022 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@Ziyear
Copy link

Ziyear commented Apr 26, 2022

spring-boot:2.6.7
spring-webmvc:5.3.19

I have configured access to local static resources

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/image1/**").addResourceLocations("file:D:\\Data\\TD\\image1\\");
    }

When I request a path: http://localhost:8080/image1/P/test%20simple.jpg Prompt 404 Not Found

Was found during debugging org.springframework.web.servlet.resource.PathResourceResolver#encodeOrDecodeIfNecessary

The code here will change the URI to: P/test%2520simple.jpg

The code is org.springframework.web.servlet.resource.PathResourceResolver on line 157

The pathToUse variable becomes P/test%2520simple.jpg

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 26, 2022
@bclozel
Copy link
Member

bclozel commented Apr 26, 2022

Duplicates #27791

@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 26, 2022
@bclozel bclozel closed this as completed Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants