|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.web.method.support.ModelAndViewContainer
public class ModelAndViewContainer
Provides access to the model and a place to record model and view related decisions made by
HandlerMethodArgumentResolvers or a HandlerMethodReturnValueHandler.
In addition to storing model attributes and a view, the ModelAndViewContainer also provides
a setResolveView(boolean) flag, which can be used to request or bypass a view resolution phase.
This is most commonly used from HandlerMethodReturnValueHandlers but in some cases may also be
used from HandlerMethodArgumentResolvers such as when a handler method accepts an argument
providing access to the response. When that is the case, if the handler method returns null,
view resolution is skipped.
| Constructor Summary | |
|---|---|
ModelAndViewContainer()
Create a ModelAndViewContainer instance with a BindingAwareModelMap. |
|
ModelAndViewContainer(ModelMap model)
Create a ModelAndViewContainer instance with the given ModelMap instance. |
|
| Method Summary | |
|---|---|
void |
addAllAttributes(Map<String,?> attributes)
Copy all attributes in the supplied Map into the model |
void |
addAttribute(String name,
Object value)
Add the supplied attribute under the given name. |
boolean |
containsAttribute(String name)
Whether model contains an attribute of the given name. |
Object |
getAttribute(String name)
|
ModelMap |
getModel()
|
Object |
getView()
|
String |
getViewName()
|
boolean |
isResolveView()
|
void |
mergeAttribute(String name,
Object value)
Add the given attribute if the model does not already contain such an attribute. |
void |
setResolveView(boolean resolveView)
|
void |
setView(Object view)
|
void |
setViewName(String viewName)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ModelAndViewContainer()
ModelAndViewContainer instance with a BindingAwareModelMap.
public ModelAndViewContainer(ModelMap model)
ModelAndViewContainer instance with the given ModelMap instance.
model - the model to use| Method Detail |
|---|
public ModelMap getModel()
public String getViewName()
nullpublic void setViewName(String viewName)
viewName - the name of the view to use for view resolutionpublic Object getView()
public void setView(Object view)
view - the view instance to use for view resolutionpublic boolean isResolveView()
true), or should be bypassed (false)public void setResolveView(boolean resolveView)
resolveView - whether the view resolution is requested (true), or should be bypassed (false)public boolean containsAttribute(String name)
name - the name of the model attribute
true if the model contains an attribute by that name and the name is not an empty stringpublic Object getAttribute(String name)
name - the attribute to get from the model
null
public void addAttribute(String name,
Object value)
name - the name of the model attribute (never null)value - the model attribute value (can be null)public void addAllAttributes(Map<String,?> attributes)
public void mergeAttribute(String name,
Object value)
name - the name of the attribute to check and addvalue - the value of the attribute
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||