Skip to content

RequestMapping maps root-controller handler methods with double slashes [SPR-12975] #17566

@spring-projects-issues

Description

@spring-projects-issues

Christopher Smith opened SPR-12975 and commented

The handler-mapping builder is adding an extra slash to the beginning of handler mappings, causing MockMvc tests to fail because of strict matching in MockMvc.

@Controller
@CompileStatic
@RequestMapping("/")
class StaticPagesHtmlController {
    @RequestMapping("")
    public String home() {
        "index2"
    }

    @RequestMapping("about")
    String aboutMain() {
        "about/index"
    }
}
2015-05-04 01:37:09.954  INFO   --- [           main] ilder$StaticRequestMappingHandlerMapping : Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.artsquare.gallery.web.html.StaticPagesHtmlController.home()
2015-05-04 01:37:09.954  INFO   --- [           main] ilder$StaticRequestMappingHandlerMapping : Mapped "{[//about],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.artsquare.gallery.web.html.StaticPagesHtmlController.aboutMain()

It looks like a potential defensive rule that adds the slash to the root-root mapping is also adding erroneous, breaking, slashes to the other mappings.


Affects: 4.1.6

Issue Links:

Referenced from: commits bf423b2, a80d0e8, 76beb36

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions