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

Wrong path mapping combination between type-level and method-level @RequestMapping on @Controller [SPR-7970] #12625

Closed
spring-projects-issues opened this issue Feb 17, 2011 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 17, 2011

Ludovic Praud opened SPR-7970 and commented

With the following code, the org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping fails to #determineUrlsForHandler.

@Controller
@RequestMapping("/users")
public class DemoController {
    @RequestMapping(value = "/users", method = GET)
    public String getUsers()
    {
        return "users/users";
    }
}

The wanted URL mapping is '/users/users' but the generated path is '/users'. So when browsing /users/users we got HTTP 404.

The error is due to the use of org.springframework.util.AntPathMatcher.combine(String, String) to concatenate the type-level path and the method-level path that only return the method-level path which is not expected.

The combine method return the second method argument pattern2 when the pattern1 matches pattern2.
I don't known if it is the AntPathMatcher.combine(...) method which is wrong or the use of it by org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.determineUrlsForHandler(String)


Affects: 3.0.5

Issue Links:

Referenced from: commits 9833a4c

@spring-projects-issues
Copy link
Collaborator Author

Ludovic Praud commented

Hello, any news about this bug ? Will it be in 3.1 ?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 13, 2011

Rossen Stoyanchev commented

Apologies we didn't get to this for 3.1 even though a related issue (#13500) was fixed. Maybe you already know this but a temporary workaround would be to move the separating slash to the class-level annotation:

@Controller
@RequestMapping("/users/")
public class DemoController {
    @RequestMapping(value = "users", method = GET)
    public String getUsers()
    {
        return "users/users";
    }
}

@spring-projects-issues
Copy link
Collaborator Author

Ludovic Praud commented

Thanks for the workaround, I was no aware of it. But right now we changed /users/users to /accounts/users which better match our intentions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants