Class ModelAndViewResolverMethodReturnValueHandler
- All Implemented Interfaces:
org.springframework.web.method.support.HandlerMethodReturnValueHandler
true for
all return types).
The return value is handled either with a ModelAndViewResolver
or otherwise by regarding it as a model attribute if it is a non-simple
type. If neither of these succeeds (essentially simple type other than
String), UnsupportedOperationException is raised.
Note: This class is primarily needed to support
ModelAndViewResolver, which unfortunately cannot be properly
adapted to the HandlerMethodReturnValueHandler contract since the
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter) method
cannot be implemented. Hence ModelAndViewResolvers are limited
to always being invoked at the end after all other return value
handlers have been given a chance. It is recommended to re-implement
a ModelAndViewResolver as HandlerMethodReturnValueHandler,
which also provides better access to the return type and method information.
- Since:
- 3.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionModelAndViewResolverMethodReturnValueHandler(List<ModelAndViewResolver> mavResolvers) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleReturnValue(Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest) booleansupportsReturnType(org.springframework.core.MethodParameter returnType) Always returnstrue.
-
Constructor Details
-
ModelAndViewResolverMethodReturnValueHandler
public ModelAndViewResolverMethodReturnValueHandler(@Nullable List<ModelAndViewResolver> mavResolvers) Create a new instance.
-
-
Method Details
-
supportsReturnType
public boolean supportsReturnType(org.springframework.core.MethodParameter returnType) Always returnstrue. See class-level note.- Specified by:
supportsReturnTypein interfaceorg.springframework.web.method.support.HandlerMethodReturnValueHandler
-
handleReturnValue
public void handleReturnValue(@Nullable Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest) throws Exception - Specified by:
handleReturnValuein interfaceorg.springframework.web.method.support.HandlerMethodReturnValueHandler- Throws:
Exception
-