Skip to content

UrlHandlerFilter should not strip the trailing slash from the contextPath URL #33565

@bdshadow

Description

@bdshadow

Although #33444 has been fixed for root URLs, it looks like there is still a problem with the UrlHandlerFilter when server.servlet.contextPath is specified.

Here is a minimal application to reproduce it: https://github.com/bdshadow/SpringTrailingSlashTestProject

server.servlet.contextPath=/myApp

And use the following UrlHandlerFilter:

        UrlHandlerFilter filter = UrlHandlerFilter
            .trailingSlashHandler("/**").wrapRequest()
            .build();

And in this case, both http://localhost:8080/myApp/greeting and http://localhost:8080/myApp/greeting work fine, however,
http://localhost:8080/myApp and http://localhost:8080/myApp/ don't and return 404.

Controller for the root looks like this:

@RestController
@RequestMapping("/")
public class MyController {
    @GetMapping(value = {"/", "greeting"})
    public String greeting() {
        return "Hello world!";
    }
}

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions