views:

1047

answers:

1

Consider this Spring MVC Controller:

@Controller
@RequestMapping("/test*")
public class TestController {

  @RequestMapping(method = RequestMethod.GET)
  public void doStuff(Model model){
    ...
  }

  @RequestMapping(params = "myParam")
  public void doStuff(@RequestParam("myParam") int myParam, Model model){
    ...
  }

}

When I put this into my browser:

mySite.com/test.html?myParam=1

I expected an AmbiguousHandlerMappingException or something, since both methods seem to match the URL.

But actually the first method got called. Does anybody know why?

+1  A: 

This smells like a bug. If you add method=GET to the second handler, it works as expected, so that's the workaround.

I've filed a bug report on this, hopefully it'll be addressed.

http://jira.springframework.org/browse/SPR-5772

skaffman
This issue will be fixed in the RC1 release.
skaffman
SPR-5772 is now resolved and will be in RC1.
skaffman