Class RedirectAttributesModelMap

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<String,Object>
org.springframework.ui.ModelMap
org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, org.springframework.ui.Model, RedirectAttributes

public class RedirectAttributesModelMap extends org.springframework.ui.ModelMap implements RedirectAttributes
A ModelMap implementation of RedirectAttributes that formats values as Strings using a DataBinder. Also provides a place to store flash attributes so they can survive a redirect without the need to be embedded in the redirect URL.
Since:
3.1
Author:
Rossen Stoyanchev
See Also:
  • Constructor Details

    • RedirectAttributesModelMap

      public RedirectAttributesModelMap()
      Default constructor without a DataBinder. Attribute values are converted to String via AbstractMap.toString().
    • RedirectAttributesModelMap

      public RedirectAttributesModelMap(@Nullable org.springframework.validation.DataBinder dataBinder)
      Constructor with a DataBinder.
      Parameters:
      dataBinder - used to format attribute values as Strings
  • Method Details

    • getFlashAttributes

      public Map<String,?> getFlashAttributes()
      Return the attributes candidate for flash storage or an empty Map.
      Specified by:
      getFlashAttributes in interface RedirectAttributes
    • addAttribute

      public RedirectAttributesModelMap addAttribute(String attributeName, @Nullable Object attributeValue)

      Formats the attribute value as a String before adding it.

      Specified by:
      addAttribute in interface org.springframework.ui.Model
      Specified by:
      addAttribute in interface RedirectAttributes
      Overrides:
      addAttribute in class org.springframework.ui.ModelMap
    • addAttribute

      public RedirectAttributesModelMap addAttribute(Object attributeValue)

      Formats the attribute value as a String before adding it.

      Specified by:
      addAttribute in interface org.springframework.ui.Model
      Specified by:
      addAttribute in interface RedirectAttributes
      Overrides:
      addAttribute in class org.springframework.ui.ModelMap
    • addAllAttributes

      public RedirectAttributesModelMap addAllAttributes(@Nullable Collection<?> attributeValues)

      Each attribute value is formatted as a String before being added.

      Specified by:
      addAllAttributes in interface org.springframework.ui.Model
      Specified by:
      addAllAttributes in interface RedirectAttributes
      Overrides:
      addAllAttributes in class org.springframework.ui.ModelMap
    • addAllAttributes

      public RedirectAttributesModelMap addAllAttributes(@Nullable Map<String,?> attributes)

      Each attribute value is formatted as a String before being added.

      Specified by:
      addAllAttributes in interface org.springframework.ui.Model
      Overrides:
      addAllAttributes in class org.springframework.ui.ModelMap
    • mergeAttributes

      public RedirectAttributesModelMap mergeAttributes(@Nullable Map<String,?> attributes)

      Each attribute value is formatted as a String before being merged.

      Specified by:
      mergeAttributes in interface org.springframework.ui.Model
      Specified by:
      mergeAttributes in interface RedirectAttributes
      Overrides:
      mergeAttributes in class org.springframework.ui.ModelMap
    • asMap

      public Map<String,Object> asMap()
      Specified by:
      asMap in interface org.springframework.ui.Model
    • put

      public Object put(String key, @Nullable Object value)

      The value is formatted as a String before being added.

      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class HashMap<String,Object>
    • putAll

      public void putAll(@Nullable Map<? extends String,? extends Object> map)

      Each value is formatted as a String before being added.

      Specified by:
      putAll in interface Map<String,Object>
      Overrides:
      putAll in class HashMap<String,Object>
    • addFlashAttribute

      public RedirectAttributes addFlashAttribute(String attributeName, @Nullable Object attributeValue)
      Description copied from interface: RedirectAttributes
      Add the given flash attribute.
      Specified by:
      addFlashAttribute in interface RedirectAttributes
      Parameters:
      attributeName - the attribute name; never null
      attributeValue - the attribute value; may be null
    • addFlashAttribute

      public RedirectAttributes addFlashAttribute(Object attributeValue)
      Description copied from interface: RedirectAttributes
      Add the given flash storage using a generated name.
      Specified by:
      addFlashAttribute in interface RedirectAttributes
      Parameters:
      attributeValue - the flash attribute value; never null