Package org.springframework.ui
Interface Model
- All Known Subinterfaces:
RedirectAttributes
- All Known Implementing Classes:
BindingAwareModelMap
,ExtendedModelMap
,RedirectAttributesModelMap
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
.- Since:
- 2.5.1
- Author:
- Juergen Hoeller
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Model
addAllAttributes(Collection<?> attributeValues)
Copy all attributes in the suppliedCollection
into thisMap
, using attribute name generation for each element.Model
addAllAttributes(Map<String,?> attributes)
Copy all attributes in the suppliedMap
into thisMap
.Model
addAttribute(Object attributeValue)
Add the supplied attribute to thisMap
using agenerated name
.Model
addAttribute(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.boolean
containsAttribute(String attributeName)
Does this model contain an attribute of the given name?Model
mergeAttributes(Map<String,?> attributes)
Copy all attributes in the suppliedMap
into thisMap
, with existing objects of the same name taking precedence (i.e.
Method Detail
addAttribute
Model addAttribute(String attributeName, Object attributeValue)
Add the supplied attribute under the supplied name.- Parameters:
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 thisMap
using agenerated name
.Note: Empty Collections
are not added to the model when using this method because we cannot correctly determine the true convention name. View code should check fornull
rather than for empty collections as is already done by JSTL tags.- Parameters:
attributeValue
- the model attribute value (nevernull
)
addAllAttributes
Model addAllAttributes(Collection<?> attributeValues)
Copy all attributes in the suppliedCollection
into thisMap
, using attribute name generation for each element.- See Also:
addAttribute(Object)
addAllAttributes
Model addAllAttributes(Map<String,?> attributes)
Copy all attributes in the suppliedMap
into thisMap
.- See Also:
addAttribute(String, Object)
mergeAttributes
Model mergeAttributes(Map<String,?> attributes)
Copy all attributes in the suppliedMap
into 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?- Parameters:
attributeName
- the name of the model attribute (nevernull
)- Returns:
- whether this model contains a corresponding attribute