程序包 cn.taketoday.ui

类 ModelMap

所有已实现的接口:
Model, Serializable, Cloneable, Map<String,Object>
直接已知子类:
ExtendedModelMap

public class ModelMap extends LinkedHashMap<String,Object> implements Model
Implementation of Map for use when building model data for use with UI tools. Supports chained calls and generation of model attribute names.

This class serves as generic model holder for Servlet MVC but is not tied to it. Check out the Model interface for an interface variant.

从以下版本开始:
4.0 2022/4/8 22:58
作者:
Rob Harrop, Juergen Hoeller, Harry Yang
另请参阅:
  • Conventions.getVariableName(java.lang.Object)
  • ModelAndView
  • 序列化表格
  • 构造器详细资料

    • ModelMap

      public ModelMap()
      Construct a new, empty ModelMap.
    • ModelMap

      public ModelMap(String attributeName, @Nullable Object attributeValue)
      Construct a new ModelMap containing the supplied attribute under the supplied name.
      另请参阅:
    • ModelMap

      public ModelMap(Object attributeValue)
      Construct a new ModelMap containing the supplied attribute. Uses attribute name generation to generate the key for the supplied model object.
      另请参阅:
  • 方法详细资料

    • addAttribute

      public ModelMap addAttribute(String attributeName, @Nullable Object attributeValue)
      Add the supplied attribute under the supplied name.
      指定者:
      addAttribute 在接口中 Model
      参数:
      attributeName - the name of the model attribute (never null)
      attributeValue - the model attribute value (can be null)
    • addAttribute

      public ModelMap 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.

      指定者:
      addAttribute 在接口中 Model
      参数:
      attributeValue - the model attribute value (never null)
    • addAllAttributes

      public ModelMap addAllAttributes(@Nullable Collection<?> attributeValues)
      Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.
      指定者:
      addAllAttributes 在接口中 Model
      另请参阅:
    • addAllAttributes

      public ModelMap addAllAttributes(@Nullable Map<String,?> attributes)
      Copy all attributes in the supplied Map into this Map.
      指定者:
      addAllAttributes 在接口中 Model
      另请参阅:
    • mergeAttributes

      public ModelMap mergeAttributes(@Nullable 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).
      指定者:
      mergeAttributes 在接口中 Model
    • containsAttribute

      public boolean containsAttribute(String attributeName)
      Does this model contain an attribute of the given name?
      指定者:
      containsAttribute 在接口中 Model
      参数:
      attributeName - the name of the model attribute (never null)
      返回:
      whether this model contains a corresponding attribute
    • getAttribute

      @Nullable public Object getAttribute(String attributeName)
      Return the attribute value for the given name, if any.
      指定者:
      getAttribute 在接口中 Model
      参数:
      attributeName - the name of the model attribute (never null)
      返回:
      the corresponding attribute value, or null if none
    • setAttribute

      public void setAttribute(String name, @Nullable Object value)
      从接口复制的说明: Model
      Stores an attribute in this request. Attributes are reset between requests..
      指定者:
      setAttribute 在接口中 Model
      参数:
      name - a String specifying the name of the attribute
      value - the Object to be stored
    • removeAttribute

      public Object removeAttribute(String name)
      从接口复制的说明: Model
      Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.
      指定者:
      removeAttribute 在接口中 Model
      参数:
      name - a String specifying the name of the attribute to remove
      返回:
      the last value of the attribute, if any
    • asMap

      public Map<String,Object> asMap()
      从接口复制的说明: Model
      Convert this model to a Map
      指定者:
      asMap 在接口中 Model
    • attributeNames

      public Iterator<String> attributeNames()
      从接口复制的说明: Model
      Return the names Iterator.
      指定者:
      attributeNames 在接口中 Model