public class ExtendedModelMap extends ModelMap implements Model
ModelMap
that implements the Model
interface.
Java 5 specific like the Model
interface itself.
This is an implementation class exposed to handler methods by Spring MVC, typically via
a declaration of the Model
interface. There is no need to
build it within user code; a plain ModelMap
or even a just
a regular Map
with String keys will be good enough to return a user model.
Constructor and Description |
---|
ExtendedModelMap() |
Modifier and Type | Method and Description |
---|---|
ExtendedModelMap |
addAllAttributes(java.util.Collection<?> attributeValues)
Copy all attributes in the supplied
Collection into this
Map , using attribute name generation for each element. |
ExtendedModelMap |
addAllAttributes(java.util.Map<java.lang.String,?> attributes)
Copy all attributes in the supplied
Map into this Map . |
ExtendedModelMap |
addAttribute(java.lang.Object attributeValue)
Add the supplied attribute to this
Map using a
generated name . |
ExtendedModelMap |
addAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
Add the supplied attribute under the supplied name.
|
java.util.Map<java.lang.String,java.lang.Object> |
asMap()
Return the current set of model attributes as a Map.
|
ExtendedModelMap |
mergeAttributes(java.util.Map<java.lang.String,?> attributes)
Copy all attributes in the supplied
Map into this Map ,
with existing objects of the same name taking precedence (i.e. |
containsAttribute, getAttribute
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
finalize, getClass, notify, notifyAll, wait, wait, wait
containsAttribute, getAttribute
public ExtendedModelMap addAttribute(java.lang.String attributeName, @Nullable java.lang.Object attributeValue)
ModelMap
addAttribute
in interface Model
addAttribute
in class ModelMap
attributeName
- the name of the model attribute (never null
)attributeValue
- the model attribute value (can be null
)public ExtendedModelMap addAttribute(java.lang.Object attributeValue)
ModelMap
Map
using a
generated 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 for null
rather
than for empty collections as is already done by JSTL tags.
addAttribute
in interface Model
addAttribute
in class ModelMap
attributeValue
- the model attribute value (never null
)public ExtendedModelMap addAllAttributes(@Nullable java.util.Collection<?> attributeValues)
ModelMap
Collection
into this
Map
, using attribute name generation for each element.addAllAttributes
in interface Model
addAllAttributes
in class ModelMap
ModelMap.addAttribute(Object)
public ExtendedModelMap addAllAttributes(@Nullable java.util.Map<java.lang.String,?> attributes)
ModelMap
Map
into this Map
.addAllAttributes
in interface Model
addAllAttributes
in class ModelMap
ModelMap.addAttribute(String, Object)
public ExtendedModelMap mergeAttributes(@Nullable java.util.Map<java.lang.String,?> attributes)
ModelMap
Map
into this Map
,
with existing objects of the same name taking precedence (i.e. not getting
replaced).mergeAttributes
in interface Model
mergeAttributes
in class ModelMap