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:
Rossen Stoyanchev
2013-08-07 18:43:13 -04:00
parent 172a0b9f5d
commit 82a26024ae
5 changed files with 135 additions and 21 deletions

View File

@@ -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));
}
/**