Allow @ResponseBody on the type level
This change enables having @ResponseBody on the type-level in which case it inherited and does not need to be added on the method level. For added convenience, there is also a new @RestController annotation, a meta-annotation in turn annotated with @Controller and @ResponseBody. Classes with the new annotation do not need to have @ResponseBody declared on the method level as it is inherited. Issue: SPR-10814
This commit is contained in:
@@ -81,7 +81,8 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
return returnType.getMethodAnnotation(ResponseBody.class) != null;
|
||||
return ((AnnotationUtils.findAnnotation(returnType.getDeclaringClass(), ResponseBody.class) != null)
|
||||
|| (returnType.getMethodAnnotation(ResponseBody.class) != null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user