Browse Source

Switch to AnnotatedElementUtils.findXxx for @MVC

Issue: SPR-12296
pull/903/head
Rossen Stoyanchev 10 years ago
parent
commit
86fd0afbf2
  1. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java
  2. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

4
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java

@ -379,7 +379,7 @@ public class MvcUriComponentsBuilder { @@ -379,7 +379,7 @@ public class MvcUriComponentsBuilder {
private static String getTypeRequestMapping(Class<?> controllerType) {
Assert.notNull(controllerType, "'controllerType' must not be null");
String annotType = RequestMapping.class.getName();
AnnotationAttributes attrs = AnnotatedElementUtils.getAnnotationAttributes(controllerType, annotType);
AnnotationAttributes attrs = AnnotatedElementUtils.findAnnotationAttributes(controllerType, annotType);
if (attrs == null) {
return "/";
}
@ -396,7 +396,7 @@ public class MvcUriComponentsBuilder { @@ -396,7 +396,7 @@ public class MvcUriComponentsBuilder {
private static String getMethodRequestMapping(Method method) {
String annotType = RequestMapping.class.getName();
AnnotationAttributes attrs = AnnotatedElementUtils.getAnnotationAttributes(method, annotType);
AnnotationAttributes attrs = AnnotatedElementUtils.findAnnotationAttributes(method, annotType);
if (attrs == null) {
throw new IllegalArgumentException("No @RequestMapping on: " + method.toGenericString());
}

4
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

@ -246,13 +246,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -246,13 +246,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
if (annotatedElement instanceof Class<?>) {
Class<?> type = (Class<?>) annotatedElement;
annotation = AnnotationUtils.findAnnotation(type, RequestMapping.class);
attributes = AnnotatedElementUtils.getAnnotationAttributes(type, annotationType);
attributes = AnnotatedElementUtils.findAnnotationAttributes(type, annotationType);
customCondition = getCustomTypeCondition(type);
}
else {
Method method = (Method) annotatedElement;
annotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
attributes = AnnotatedElementUtils.getAnnotationAttributes(method, annotationType);
attributes = AnnotatedElementUtils.findAnnotationAttributes(method, annotationType);
customCondition = getCustomMethodCondition(method);
}
RequestMappingInfo info = null;

Loading…
Cancel
Save