Skip to content

@RequestMapping matching should be insensitive to trailing slashes [SPR-5636] #10307

Closed
@spring-projects-issues

Description

@spring-projects-issues

Grzegorz Borkowski opened SPR-5636 and commented

For full discussion, see my article: http://grzegorzborkowski.blogspot.com/2009/03/test-drive-of-spring-30-m2-rest-support.html

Some citations from it:

"For RESTful web services (...) URLs actually represent virtual directories. This means that common rule "trailing slash doesn't matter" (especially for URL representing "list of resources") should be respected: http://mydomain/restservice/v1/projects address is equivalent to http://mydomain/restservice/v1/projects/ address. If you consider that each project is also the container for its tasks or assignments, then also http://mydomain/restservice/v1/projects/MyProject should be equivalent to http://mydomain/restservice/v1/projects/MyProject/, etc."

@PathMapping annotation is broken when it comes to handling those trailing slashes:

"If I mark controller class with @RequestMapping("/projects") then only request without trailing slash will be matched. If trailing slash is appended to the actual request, we get 404 response. What's worse, method-level annotation will not be appended to base URL in this case. So we have to change it to @RequestMapping("/projects/*"). Now methods will work, but if you send request to base url to get list of projects, and forget the slash at the end, you will get 404 response again. That's very bad in my opinion. JAX-RS handles it properly: see JAX-RS's @Path Javadoc."

For reference: https://jsr311.dev.java.net/nonav/releases/1.0/javax/ws/rs/Path.html

This issue is related also to #10302.


Affects: 3.0 M3

Issue Links:

Referenced from: commits c225b44

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