接口 Model
- 所有已知子接口:
RedirectAttributes
public interface Model
Java-5-specific interface that defines a holder for model attributes. Primarily designed for adding attributes to the model. Allows for accessing the overall model as ajava.util.Map.- 从以下版本开始:
- 2.5.1
- 作者:
- Juergen Hoeller
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 ModeladdAllAttributes(Collection<?> attributeValues)Copy all attributes in the suppliedCollectioninto thisMap, using attribute name generation for each element.ModeladdAllAttributes(Map<String,?> attributes)Copy all attributes in the suppliedMapinto thisMap.ModeladdAttribute(Object attributeValue)Add the supplied attribute to thisMapusing agenerated name.ModeladdAttribute(String attributeName, Object attributeValue)Add the supplied attribute under the supplied name.Map<String,Object>asMap()Return the current set of model attributes as a Map.booleancontainsAttribute(String attributeName)Does this model contain an attribute of the given name?ModelmergeAttributes(Map<String,?> attributes)Copy all attributes in the suppliedMapinto thisMap, with existing objects of the same name taking precedence (i.e. not getting replaced).
方法详细资料
addAttribute
Model addAttribute(String attributeName, Object attributeValue)
Add the supplied attribute under the supplied name.- 参数:
attributeName- the name of the model attribute (nevernull)attributeValue- the model attribute value (can benull)
addAttribute
Model addAttribute(Object attributeValue)
Add the supplied attribute to thisMapusing agenerated name.Note: Empty Collectionsare not added to the model when using this method because we cannot correctly determine the true convention name. View code should check fornullrather than for empty collections as is already done by JSTL tags.- 参数:
attributeValue- the model attribute value (nevernull)
addAllAttributes
Model addAllAttributes(Collection<?> attributeValues)
Copy all attributes in the suppliedCollectioninto thisMap, using attribute name generation for each element.- 另请参阅:
addAttribute(Object)
addAllAttributes
Model addAllAttributes(Map<String,?> attributes)
Copy all attributes in the suppliedMapinto thisMap.
mergeAttributes
Model mergeAttributes(Map<String,?> attributes)
Copy all attributes in the suppliedMapinto thisMap, with existing objects of the same name taking precedence (i.e. not getting replaced).
containsAttribute
boolean containsAttribute(String attributeName)
Does this model contain an attribute of the given name?- 参数:
attributeName- the name of the model attribute (nevernull)- 返回:
- whether this model contains a corresponding attribute