| java.lang.Object | |
| ↳ | org.springframework.web.servlet.ModelAndView |
Holder for both Model and View in the web MVC framework. Note that these are entirely distinct. This class merely holds both to make it possible for a controller to return both model and view in a single return value.
Represents a model and view returned by a handler, to be resolved by a DispatcherServlet. The view can take the form of a String view name which will need to be resolved by a ViewResolver object; alternatively a View object can be specified directly. The model is a Map, allowing the use of multiple objects keyed by name.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor for bean-style usage: populating bean
properties instead of passing in constructor arguments.
| |||||||||||
Convenient constructor when there is no model data to expose.
| |||||||||||
Convenient constructor when there is no model data to expose.
| |||||||||||
Creates new ModelAndView given a view name and a model.
| |||||||||||
Creates new ModelAndView given a View object and a model.
| |||||||||||
Convenient constructor to take a single model object.
| |||||||||||
Convenient constructor to take a single model object.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Add all attributes contained in the provided Map to the model.
| |||||||||||
Add an attribute to the model.
| |||||||||||
Add an attribute to the model using parameter name generation.
| |||||||||||
Clear the state of this ModelAndView object.
| |||||||||||
Return the model map.
| |||||||||||
Return the underlying
ModelMap instance (never null). | |||||||||||
Return the View object, or
null if we are using a view name
to be resolved by the DispatcherServlet via a ViewResolver. | |||||||||||
Return the view name to be resolved by the DispatcherServlet
via a ViewResolver, or
null if we are using a View object. | |||||||||||
Indicate whether or not this
ModelAndView has a view, either
as a view name or as a direct View instance. | |||||||||||
Return whether this ModelAndView object is empty,
i.e.
| |||||||||||
Return whether we use a view reference, i.e.
| |||||||||||
Set a View object for this ModelAndView.
| |||||||||||
Set a view name for this ModelAndView, to be resolved by the
DispatcherServlet via a ViewResolver.
| |||||||||||
Return diagnostic information about this model and view.
| |||||||||||
Return whether this ModelAndView object is empty as a result of a call to
clear()
i.e. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Return the model map.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Default constructor for bean-style usage: populating bean properties instead of passing in constructor arguments.
Convenient constructor when there is no model data to expose.
Can also be used in conjunction with addObject.
| viewName | name of the View to render, to be resolved by the DispatcherServlet's ViewResolver |
|---|
Convenient constructor when there is no model data to expose.
Can also be used in conjunction with addObject.
| view | View object to render |
|---|
Creates new ModelAndView given a view name and a model.
| viewName | name of the View to render, to be resolved by the DispatcherServlet's ViewResolver |
|---|---|
| model | Map of model names (Strings) to model objects
(Objects). Model entries may not be null, but the
model Map may be null if there is no model data.
|
Creates new ModelAndView given a View object and a model.
| view | View object to render |
|---|---|
| model | Map of model names (Strings) to model objects
(Objects). Model entries may not be null, but the
model Map may be null if there is no model data.
|
Convenient constructor to take a single model object.
| viewName | name of the View to render, to be resolved by the DispatcherServlet's ViewResolver |
|---|---|
| modelName | name of the single entry in the model |
| modelObject | the single model object |
Convenient constructor to take a single model object.
| view | View object to render |
|---|---|
| modelName | name of the single entry in the model |
| modelObject | the single model object |
Add all attributes contained in the provided Map to the model.
| modelMap | a Map of attributeName -> attributeValue pairs |
|---|
Add an attribute to the model.
| attributeName | name of the object to add to the model |
|---|---|
| attributeValue | object to add to the model (never null) |
Add an attribute to the model using parameter name generation.
| attributeValue | the object to add to the model (never null) |
|---|
Clear the state of this ModelAndView object. The object will be empty afterwards.
Can be used to suppress rendering of a given ModelAndView object
in the postHandle method of a HandlerInterceptor.
Return the model map. Never returns null.
To be called by application code for modifying the model.
Return the View object, or null if we are using a view name
to be resolved by the DispatcherServlet via a ViewResolver.
Return the view name to be resolved by the DispatcherServlet
via a ViewResolver, or null if we are using a View object.
Indicate whether or not this ModelAndView has a view, either
as a view name or as a direct View instance.
Return whether this ModelAndView object is empty, i.e. whether it does not hold any view and does not contain a model.
Return whether we use a view reference, i.e. true
if the view has been specified via a name to be resolved by the
DispatcherServlet via a ViewResolver.
Set a View object for this ModelAndView. Will override any pre-existing view name or View.
Set a view name for this ModelAndView, to be resolved by the DispatcherServlet via a ViewResolver. Will override any pre-existing view name or View.
Return the model map. May return null.
Called by DispatcherServlet for evaluation of the model.