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.
| Constructor: |
public ModelAndView() {
}
Default constructor for bean-style usage: populating bean
properties instead of passing in constructor arguments. |
public ModelAndView(String viewName) {
this.view = viewName;
}
Convenient constructor when there is no model data to expose.
Can also be used in conjunction with addObject. Parameters:
viewName - name of the View to render, to be resolved
by the DispatcherServlet's ViewResolver
Also see:
- addObject
|
public ModelAndView(View view) {
this.view = view;
}
Convenient constructor when there is no model data to expose.
Can also be used in conjunction with addObject. Parameters:
view - View object to render
Also see:
- addObject
|
public ModelAndView(String viewName,
Map model) {
this.view = viewName;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}
Creates new ModelAndView given a view name and a model. Parameters:
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.
|
public ModelAndView(View view,
Map model) {
this.view = view;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}
Creates new ModelAndView given a View object and a model.
Note: the supplied model data is copied into the internal
storage of this class. You should not consider to modify the supplied
Map after supplying it to this class Parameters:
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.
|
public ModelAndView(String viewName,
String modelName,
Object modelObject) {
this.view = viewName;
addObject(modelName, modelObject);
}
Convenient constructor to take a single model object. Parameters:
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
|
public ModelAndView(View view,
String modelName,
Object modelObject) {
this.view = view;
addObject(modelName, modelObject);
}
Convenient constructor to take a single model object. Parameters:
view - View object to render
modelName - name of the single entry in the model
modelObject - the single model object
|