gpt4 book ai didi

spring - modelMap.put() v/s modelMap.addAttribute()

转载 作者:行者123 更新时间:2023-12-02 06:53:44 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com