类 ModelAndViewResolverMethodReturnValueHandler
- java.lang.Object
- org.springframework.web.servlet.mvc.method.annotation.ModelAndViewResolverMethodReturnValueHandler
- 所有已实现的接口:
HandlerMethodReturnValueHandler
public class ModelAndViewResolverMethodReturnValueHandler extends Object implements HandlerMethodReturnValueHandler
This return value handler is intended to be ordered after all others as it attempts to handle _any_ return value type (i.e. returnstrue
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 theHandlerMethodReturnValueHandler
contract since theHandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
method cannot be implemented. HenceModelAndViewResolver
s 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 aModelAndViewResolver
asHandlerMethodReturnValueHandler
, which also provides better access to the return type and method information.- 从以下版本开始:
- 3.1
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 ModelAndViewResolverMethodReturnValueHandler(List<ModelAndViewResolver> mavResolvers)
Create a new instance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest)
Handle the given return value by adding attributes to the model and setting a view or setting theModelAndViewContainer.setRequestHandled(boolean)
flag totrue
to indicate the response has been handled directly.boolean
supportsReturnType(MethodParameter returnType)
Always returnstrue
.
构造器详细资料
ModelAndViewResolverMethodReturnValueHandler
public ModelAndViewResolverMethodReturnValueHandler(List<ModelAndViewResolver> mavResolvers)
Create a new instance.
方法详细资料
supportsReturnType
public boolean supportsReturnType(MethodParameter returnType)
Always returnstrue
. See class-level note.- 指定者:
supportsReturnType
在接口中HandlerMethodReturnValueHandler
- 参数:
returnType
- the method return type to check- 返回:
true
if this handler supports the supplied return type;false
otherwise
handleReturnValue
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception
从接口复制的说明:HandlerMethodReturnValueHandler
Handle the given return value by adding attributes to the model and setting a view or setting theModelAndViewContainer.setRequestHandled(boolean)
flag totrue
to indicate the response has been handled directly.- 指定者:
handleReturnValue
在接口中HandlerMethodReturnValueHandler
- 参数:
returnValue
- the value returned from the handler methodreturnType
- the type of the return value. This type must have previously been passed toHandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
which must have returnedtrue
.mavContainer
- the ModelAndViewContainer for the current requestwebRequest
- the current request- 抛出:
Exception
- if the return value handling results in an error