Spring ,有什么区别
modelMap.put("key",value);
和
modelMap.addAttribute("Key",value);
最佳答案
addAttributes 意味着检查属性名称中是否不为空 -> 请参阅来源
/**
* Add the supplied attribute under the supplied name.
* @param attributeName the name of the model attribute (never <code>null</code>)
* @param attributeValue the model attribute value (can be <code>null</code>)
*/
public ModelMap addAttribute(String attributeName, Object attributeValue) {
Assert.notNull(attributeName, "Model attribute name must not be null");
put(attributeName, attributeValue);
return this;
}
关于spring - modelMap.put() v/s modelMap.addAttribute(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15742262/