Skip to content

Two trailing slashes and the default servlet cannot resolve to a controller [SPR-12372] #16979

@spring-projects-issues

Description

@spring-projects-issues

Gaurav Khanna opened SPR-12372 and commented

If we map the DispatcherServlet as the default servlet as in:
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

And the controller has the request mapping as in:
@RequestMapping("/controller/**")

And if we have a GET request with two trailing slashes as in:
http://xxx.xxx/app/controller/REQ// [URI 1]

Then the default servlet (spring) is not able to find a mapping for it and we get a 404. However if we have a single trailing "/" then it works. Or if have multiple slashes anywhere in the REQ (together or separated) that works fine too. For instance:
http://xxx.xxx/app/controller/REQ//A [URI 2] [Here "A" could be just one character except the "/"]

Also, if we make the DispatcherServlet map to "/*" then two or more trailing "/" slashes work as well.

Should the default servlet (spring) not map URI 1 above without the wildcard in web.xml?


Affects: 3.2.1

Issue Links:

Referenced from: commits e02719e

0 votes, 5 watchers

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