public interface

Model

org.springframework.ui.Model
Known Indirect Subclasses

Class Overview

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 a java.util.Map.

Summary

Public Methods
abstract Model addAllAttributes(Map<String, ?> attributes)
Copy all attributes in the supplied Map into this Map.
abstract Model addAllAttributes(Collection<?> attributeValues)
Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.
abstract Model addAttribute(Object attributeValue)
Add the supplied attribute to this Map using a generated name.
abstract Model addAttribute(String attributeName, Object attributeValue)
Add the supplied attribute under the supplied name.
abstract Map<StringObject> asMap()
Return the current set of model attributes as a Map.
abstract boolean containsAttribute(String attributeName)
Does this model contain an attribute of the given name?
abstract Model mergeAttributes(Map<String, ?> attributes)
Copy all attributes in the supplied Map into this Map, with existing objects of the same name taking precedence (i.e.

Public Methods

public abstract Model addAllAttributes (Map<String, ?> attributes)

Copy all attributes in the supplied Map into this Map.

public abstract Model addAllAttributes (Collection<?> attributeValues)

Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.

public abstract Model addAttribute (Object attributeValue)

Add the supplied attribute to this 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.

Parameters
attributeValue the model attribute value (never null)

public abstract Model addAttribute (String attributeName, Object attributeValue)

Add the supplied attribute under the supplied name.

Parameters
attributeName the name of the model attribute (never null)
attributeValue the model attribute value (can be null)

public abstract Map<StringObject> asMap ()

Return the current set of model attributes as a Map.

public abstract boolean containsAttribute (String attributeName)

Does this model contain an attribute of the given name?

Parameters
attributeName the name of the model attribute (never null)
Returns
  • whether this model contains a corresponding attribute

public abstract Model mergeAttributes (Map<String, ?> attributes)

Copy all attributes in the supplied Map into this Map, with existing objects of the same name taking precedence (i.e. not getting replaced).