Discover controllers based on type @RequestMapping

This was supported in DefaultAnnotationHandlerMapping but not in the
RequestMappingHandlerMapping. The specific scenario where this matters
is a controller decorated with a JDK proxy. In this scenario the
HandlerMapping looks at interfaces only to decide if the bean is a
controller. The @Controller annotation is better left (and required)
on the class.

Issue: SPR-9374
This commit is contained in:
Rossen Stoyanchev 2012-05-10 16:19:14 -04:00
parent c499df2315
commit f61f4a960e
2 changed files with 56 additions and 55 deletions

View File

@ -83,7 +83,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
*/
@Override
protected boolean isHandler(Class<?> beanType) {
return AnnotationUtils.findAnnotation(beanType, Controller.class) != null;
return ((AnnotationUtils.findAnnotation(beanType, Controller.class) != null) ||
(AnnotationUtils.findAnnotation(beanType, RequestMapping.class) != null));
}
/**

View File

@ -208,8 +208,9 @@ public class HandlerMethodAnnotationDetectionTests {
}
}
// SPR-9374
@Controller
@RequestMapping
static interface MappingInterface {
@InitBinder
@ -300,8 +301,7 @@ public class HandlerMethodAnnotationDetectionTests {
}
}
@Controller
@RequestMapping
static interface MappingParameterizedInterface<A, B, C> {
@InitBinder