SPR-9062 Fix bug with ambiguous path and HTTP method request mappings
A direct path match with incorrect HTTP request method was causing another request mapping with a pattern and a correct HTTP method to be ignored. The bug affects the new @MVC support classes (i.e. RequestMappingHandlerMapping).
This commit is contained in:
@@ -1182,6 +1182,19 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||
assertEquals("myParam-42", response.getContentAsString());
|
||||
}
|
||||
|
||||
// SPR-9062
|
||||
|
||||
@Test
|
||||
public void ambiguousPathAndRequestMethod() throws Exception {
|
||||
initServletWithControllers(AmbiguousPathAndRequestMethodController.class);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/bug/EXISTING");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
assertEquals(200, response.getStatus());
|
||||
assertEquals("Pattern", response.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bridgeMethods() throws Exception {
|
||||
initServletWithControllers(TestControllerImpl.class);
|
||||
@@ -2549,6 +2562,20 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||
}
|
||||
}
|
||||
|
||||
@Controller
|
||||
static class AmbiguousPathAndRequestMethodController {
|
||||
|
||||
@RequestMapping(value = "/bug/EXISTING", method = RequestMethod.POST)
|
||||
public void directMatch(Writer writer) throws IOException {
|
||||
writer.write("Direct");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/bug/{type}", method = RequestMethod.GET)
|
||||
public void patternMatch(Writer writer) throws IOException {
|
||||
writer.write("Pattern");
|
||||
}
|
||||
}
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/test*")
|
||||
public static class BindingCookieValueController {
|
||||
|
||||
Reference in New Issue
Block a user