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

Spring MVC Ambiguous mapping for unambiguous Class and Method level RequestMapping [SPR-9532] #14166

Closed
spring-projects-issues opened this issue Jun 22, 2012 · 1 comment
Assignees
Labels
status: duplicate

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jun 22, 2012

Peter Lunneberg opened SPR-9532 and commented

I found an interesting issue using the @RequestMapping annotations at both class-level and method-level. An ambiguous mapping exception will be thrown if there is a method which maps to empty string and also a method which maps to the same path as the class-level mapping.

Example:

@Controller
@RequestMapping("/test")
public class TestController
{
    @RequestMapping("")
    public void indexHandler() { }
    
    //Should map to /test/test
    @RequestMapping("/test")
    public void subTestHandler() { }
}

From the logs in my test server it seems like it finds the class-level mapping when it is attempting to map the subTestHandler(); mapping. This is specific only to using the empty string mapping and also another method mapping which is the same as the class-level mapping.

Granted you could rename the method-level mapping, this doesn't seem like desired functionality.


Affects: 3.1.1

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 22, 2012

Rossen Stoyanchev commented

I recognize this. Both methods ends up being mapped to "/test". The less obvious is the second one. See the comments under #12625.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate
Projects
None yet
Development

No branches or pull requests

2 participants