mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
SPR-13033: Use @RequestMapping of correct class
MvcUriComponentsBuilder::fromMethodCall creates wrong URLs with derived controller classes. The @RequestMapping of the declaring class of the method that is called is used instead of the @RequstMapping of the given controller class. https://jira.spring.io/browse/SPR-13033
This commit is contained in:
+13
@@ -229,6 +229,14 @@ public class MvcUriComponentsBuilderTests {
|
||||
assertThat(uriComponents.toUriString(), endsWith("/something/else"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromMethodCallOnSubclass() {
|
||||
UriComponents uriComponents = fromMethodCall(on(ExtendedController.class).myMethod(null)).build();
|
||||
|
||||
assertThat(uriComponents.toUriString(), startsWith("http://localhost"));
|
||||
assertThat(uriComponents.toUriString(), endsWith("/extended/else"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromMethodCallWithTypeLevelUriVars() {
|
||||
UriComponents uriComponents = fromMethodCall(on(
|
||||
@@ -418,6 +426,11 @@ public class MvcUriComponentsBuilderTests {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/extended")
|
||||
static class ExtendedController extends ControllerWithMethods {
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/user/{userId}/contacts")
|
||||
static class UserContactController {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user