org.springframework.web.servlet.mvc.method.annotation.support
Class ModelAndViewMethodReturnValueHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.support.ModelAndViewMethodReturnValueHandler
- All Implemented Interfaces:
- HandlerMethodReturnValueHandler
public class ModelAndViewMethodReturnValueHandler
- extends Object
- implements HandlerMethodReturnValueHandler
Handles return values of type ModelAndView transferring their content to the ModelAndViewContainer.
If the return value is null, the ModelAndViewContainer.setResolveView(boolean) flag is set to
false to indicate view resolution is not needed.
- Since:
- 3.1
- Author:
- Rossen Stoyanchev
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ModelAndViewMethodReturnValueHandler
public ModelAndViewMethodReturnValueHandler()
supportsReturnType
public boolean supportsReturnType(MethodParameter returnType)
- Description copied from interface:
HandlerMethodReturnValueHandler
- Whether the given method return type is supported by this handler.
- Specified by:
supportsReturnType in interface HandlerMethodReturnValueHandler
- Parameters:
returnType - the method return type to check
- Returns:
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
- Description copied from interface:
HandlerMethodReturnValueHandler
- Handle the given return value by adding attributes to the model, setting the view (or view name),
or by writing to the response.
HandlerMethodReturnValueHandler implementations should also
consider whether to set ModelAndViewContainer.setResolveView(boolean), which is set to
true by default and therefore needs to be set to false explicitly if view
resolution is to be bypassed.
- Specified by:
handleReturnValue in interface HandlerMethodReturnValueHandler
- Parameters:
returnValue - the value returned from the handler methodreturnType - the type of the return value. This type must have previously been passed to
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter) and it must have returned truemavContainer - the ModelAndViewContainer for the current requestwebRequest - the current request
- Throws:
Exception - if the return value handling results in an error