public class ModelAndViewContainer extends Object
HandlerMethodArgumentResolvers and
 HandlerMethodReturnValueHandlers during the course of invocation of
 a controller method.
 The setRequestHandled(boolean) flag can be used to indicate the request
 has been handled directly and view resolution is not required.
 
A default Model is automatically created at instantiation.
 An alternate model instance may be provided via setRedirectModel(org.springframework.ui.ModelMap)
 for use in a redirect scenario. When setRedirectModelScenario(boolean) is set
 to true signalling a redirect scenario, the getModel()
 returns the redirect model instead of the default model.
| Constructor and Description | 
|---|
| ModelAndViewContainer()Create a new instance. | 
| Modifier and Type | Method and Description | 
|---|---|
| ModelAndViewContainer | addAllAttributes(Map<String,?> attributes)Copy all attributes to the underlying model. | 
| ModelAndViewContainer | addAttribute(Object value)Add the supplied attribute to the underlying model. | 
| ModelAndViewContainer | addAttribute(String name,
            Object value)Add the supplied attribute to the underlying model. | 
| boolean | containsAttribute(String name)Whether the underlying model contains the given attribute name. | 
| ModelMap | getModel()Return the model to use: the "default" or the "redirect" model. | 
| SessionStatus | getSessionStatus()Return the  SessionStatusinstance to use that can be used to
 signal that session processing is complete. | 
| Object | getView()Return the View object, or  nullif we using a view name
 to be resolved by the DispatcherServlet via a ViewResolver. | 
| String | getViewName()Return the view name to be resolved by the DispatcherServlet via a
 ViewResolver, or  nullif a View object is set. | 
| boolean | isRequestHandled()Whether the request is handled directly. | 
| boolean | isViewReference()Whether the view is a view reference specified via a name to be
 resolved by the DispatcherServlet via a ViewResolver. | 
| ModelAndViewContainer | mergeAttributes(Map<String,?> attributes)Copy attributes in the supplied  Mapwith existing objects of
 the same name taking precedence (i.e. | 
| ModelAndViewContainer | removeAttributes(Map<String,?> attributes)Remove the given attributes from the model. | 
| void | setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect)When set to  truethe default model is never used in a redirect
 scenario. | 
| void | setRedirectModel(ModelMap redirectModel)Provide a separate model instance to use in a redirect scenario. | 
| void | setRedirectModelScenario(boolean redirectModelScenario)Signal the conditions are in place for using a redirect model. | 
| void | setRequestHandled(boolean requestHandled)Signal a scenario where the request is handled directly. | 
| void | setView(Object view)Set a View object to be used by the DispatcherServlet. | 
| void | setViewName(String viewName)Set a view name to be resolved by the DispatcherServlet via a ViewResolver. | 
| String | toString()Return diagnostic information. | 
public void setViewName(String viewName)
public String getViewName()
null if a View object is set.public void setView(Object view)
public Object getView()
null if we using a view name
 to be resolved by the DispatcherServlet via a ViewResolver.public boolean isViewReference()
public void setRequestHandled(boolean requestHandled)
A HandlerMethodReturnValueHandler may use this flag to
 indicate the response has been fully handled and view resolution
 is not required (e.g. @ResponseBody).
 
A HandlerMethodArgumentResolver may also use this flag
 to indicate the presence of an argument (e.g.
 ServletResponse or OutputStream) that may lead to
 a complete response depending on the method return value.
 
The default value is true.
public boolean isRequestHandled()
public ModelMap getModel()
The default model is used if "redirectModelScenario=false" or
 if the redirect model is null (i.e. it wasn't declared as a
 method argument) and ignoreDefaultModelOnRedirect=false.
public void setRedirectModel(ModelMap redirectModel)
setRedirectModelScenario(boolean) gets set to true to signal
 a redirect scenario.public void setRedirectModelScenario(boolean redirectModelScenario)
public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect)
true the default model is never used in a redirect
 scenario. So if a redirect model is not available, an empty model is
 used instead.
 When set to false the default model can be used in a redirect
 scenario if a redirect model is not available.
 
The default setting is false.
public SessionStatus getSessionStatus()
SessionStatus instance to use that can be used to
 signal that session processing is complete.public ModelAndViewContainer addAttribute(String name, Object value)
getModel().addAttribute(String, Object).public ModelAndViewContainer addAttribute(Object value)
getModel().addAttribute(Object).public ModelAndViewContainer addAllAttributes(Map<String,?> attributes)
getModel().addAllAttributes(Map).public ModelAndViewContainer mergeAttributes(Map<String,?> attributes)
Map with existing objects of
 the same name taking precedence (i.e. not getting replaced).
 A shortcut for getModel().mergeAttributes(Map<String, ?>).public ModelAndViewContainer removeAttributes(Map<String,?> attributes)
public boolean containsAttribute(String name)
getModel().containsAttribute(String).