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:
parent
c499df2315
commit
f61f4a960e
|
|
@ -83,7 +83,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean isHandler(Class<?> beanType) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -208,8 +208,9 @@ public class HandlerMethodAnnotationDetectionTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPR-9374
|
||||||
|
|
||||||
@Controller
|
@RequestMapping
|
||||||
static interface MappingInterface {
|
static interface MappingInterface {
|
||||||
|
|
||||||
@InitBinder
|
@InitBinder
|
||||||
|
|
@ -300,8 +301,7 @@ public class HandlerMethodAnnotationDetectionTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping
|
||||||
@Controller
|
|
||||||
static interface MappingParameterizedInterface<A, B, C> {
|
static interface MappingParameterizedInterface<A, B, C> {
|
||||||
|
|
||||||
@InitBinder
|
@InitBinder
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue