我用的spring mvc开发的值钱项目使用的ModelAndView的方式返回的参数,和映射地址!
现在开发使用了spring 2.5用上了批注!返回值的传递用ModelMap。
为何原来的ModelAndView 支持addObject,但是ModelMap的这个方法就花了个横杠?
我知道是过期的意思,但是我想知道处于何目的!
(以后要是遇到同样问题如何去找,答案,希望深入了解下!)
[b]问题补充:[/b]
确实有,希望有人能解答一下!
我用的spring mvc开发的值钱项目使用的ModelAndView的方式返回的参数,和映射地址!
现在开发使用了spring 2.5用上了批注!返回值的传递用ModelMap。
为何原来的ModelAndView 支持addObject,但是ModelMap的这个方法就花了个横杠?
我知道是过期的意思,但是我想知道处于何目的!
(以后要是遇到同样问题如何去找,答案,希望深入了解下!)
[b]问题补充:[/b]
确实有,希望有人能解答一下!
读了下源代码,确实没有.
不知道你的spring到底是哪个版本.
下面是2.5.6的ModelAndView的代码:
/*
package org.springframework.web.servlet;
import java.util.Map;
import org.springframework.ui.ModelMap;
/**
Represents a model and view returned by a handler, to be resolved
@see org.springframework.web.servlet.mvc.Controller#handleRequest
*/
public class ModelAndView {
/** View instance or view name String */
private Object view;
/** Model Map */
private ModelMap model;
/**
/**
/**
addObject
./**
addObject
./**
null
, but thenull
if there is no model data.
*/
public ModelAndView(String viewName, Map model) {
this.view = viewName;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}/**
null
, but thenull
if there is no model data.
*/
public ModelAndView(View view, Map model) {
this.view = view;
if (model != null) {
getModelMap().addAllAttributes(model);
}
}/**
/**
/**
/**
null
if we are using a View object.
*/
public String getViewName() {
return (this.view instanceof String ? (String) this.view : null);
}/**
/**
null
if we are using a view name/**
ModelAndView
has a view, either/**
true
/**
null
./**
ModelMap
instance (never null
).
*/
public ModelMap getModelMap() {
if (this.model == null) {
this.model = new ModelMap();
}
return this.model;
}/**
null
./**
null
)/**
null
)/**
/**
Can be used to suppress rendering of a given ModelAndView object
postHandle
method of a HandlerInterceptor./**
/**
false
if any additional state was added to the instance/**