Check all HandlerMapping beans for named mappings
Related to (but not required by) SPR-16336.
This commit is contained in:
parent
dad9ed83b7
commit
e6fef9555d
|
@ -444,9 +444,15 @@ public class MvcUriComponentsBuilder {
|
|||
*/
|
||||
public static MethodArgumentBuilder fromMappingName(@Nullable UriComponentsBuilder builder, String name) {
|
||||
WebApplicationContext wac = getWebApplicationContext();
|
||||
Assert.notNull(wac, "Cannot lookup handler method mappings without WebApplicationContext");
|
||||
RequestMappingInfoHandlerMapping mapping = wac.getBean(RequestMappingInfoHandlerMapping.class);
|
||||
List<HandlerMethod> handlerMethods = mapping.getHandlerMethodsForMappingName(name);
|
||||
Assert.notNull(wac, "No WebApplicationContext. ");
|
||||
Map<String, RequestMappingInfoHandlerMapping> map = wac.getBeansOfType(RequestMappingInfoHandlerMapping.class);
|
||||
List<HandlerMethod> handlerMethods = null;
|
||||
for (RequestMappingInfoHandlerMapping mapping : map.values()) {
|
||||
handlerMethods = mapping.getHandlerMethodsForMappingName(name);
|
||||
if (handlerMethods != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (handlerMethods == null) {
|
||||
throw new IllegalArgumentException("Mapping not found: " + name);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue