类 RedirectModel

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<String,Object>
cn.taketoday.ui.ModelMap
cn.taketoday.web.view.RedirectModel
所有已实现的接口:
cn.taketoday.ui.Model, Serializable, Cloneable, Comparable<RedirectModel>, Map<String,Object>

public class RedirectModel extends cn.taketoday.ui.ModelMap implements Serializable, Comparable<RedirectModel>
A specialization of the Model interface that controllers can use to select attributes for a redirect scenario. Since the intent of adding redirect attributes is very explicit -- i.e. to be used for a redirect URL, attribute values may be formatted as Strings and stored that way to make them eligible to be appended to the query string or expanded as URI variables in cn.taketoday.web.view.RedirectView.

Example usage in an @Controller:

 @RequestMapping(value = "/accounts", method = HttpMethod.POST)
 public String handle(Account account, BindingResult result, RedirectModel redirectAttrs) {
   if (result.hasErrors()) {
     return "accounts/new";
   }
   // Save account ...
   redirectAttrs.addAttribute("id", account.getId());
   redirectAttrs.addAttribute("message", "Account created!");
   return "redirect:/accounts/{id}";
 }
 
从以下版本开始:
2.3.3 2018-11-18 16:39
作者:
Harry Yang
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • INPUT_ATTRIBUTE

      public static final String INPUT_ATTRIBUTE
      Name of request attribute that holds a RedirectModel with "input" redirect attributes saved by a previous request, if any.
      另请参阅:
    • OUTPUT_ATTRIBUTE

      public static final String OUTPUT_ATTRIBUTE
      Name of request attribute that holds the "output" RedirectModel with attributes to save for a subsequent request.
      另请参阅:
    • targetRequestPath

      @Nullable private String targetRequestPath
    • targetRequestParams

      private final cn.taketoday.util.MultiValueMap<String,String> targetRequestParams
    • expirationTime

      private long expirationTime
  • 构造器详细资料

    • RedirectModel

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

      public RedirectModel(String attributeName, @Nullable Object attributeValue)
      Construct a new ModelMap containing the supplied attribute under the supplied name.
      另请参阅:
      • ModelMap.setAttribute(String, Object)
  • 方法详细资料

    • setTargetRequestPath

      public void setTargetRequestPath(@Nullable String path)
      Provide a URL path to help identify the target request for this RedirectModel.

      The path may be absolute (e.g. "/application/resource") or relative to the current request (e.g. "../resource").

      从以下版本开始:
      4.0
    • getTargetRequestPath

      @Nullable public String getTargetRequestPath()
      Return the target URL path (or null if none specified).
      从以下版本开始:
      4.0
    • addTargetRequestParams

      public void addTargetRequestParams(@Nullable cn.taketoday.util.MultiValueMap<String,String> params)
      Provide request parameters identifying the request for this RedirectModel.
      参数:
      params - a Map with the names and values of expected parameters
      从以下版本开始:
      4.0
    • addTargetRequestParam

      public void addTargetRequestParam(String name, String value)
      Provide a request parameter identifying the request for this RedirectModel.
      参数:
      name - the expected parameter name (skipped if empty)
      value - the expected value (skipped if empty)
      从以下版本开始:
      4.0
    • getTargetRequestParams

      public cn.taketoday.util.MultiValueMap<String,String> getTargetRequestParams()
      Return the parameters identifying the target request, or an empty map.
      从以下版本开始:
      4.0
    • startExpirationPeriod

      public void startExpirationPeriod(int timeToLive)
      Start the expiration period for this instance.
      参数:
      timeToLive - the number of seconds before expiration
      从以下版本开始:
      4.0
    • setExpirationTime

      public void setExpirationTime(long expirationTime)
      Set the expiration time for the RedirectModel. This is provided for serialization purposes but can also be used instead startExpirationPeriod(int).
      从以下版本开始:
      4.0
    • getExpirationTime

      public long getExpirationTime()
      Return the expiration time for the RedirectModel or -1 if the expiration period has not started.
      从以下版本开始:
      4.0
    • isExpired

      public boolean isExpired()
      Return whether this instance has expired depending on the amount of elapsed time since the call to startExpirationPeriod(int).
      从以下版本开始:
      4.0
    • compareTo

      public int compareTo(RedirectModel other)
      Compare two RedirectModels and prefer the one that specifies a target URL path or has more target URL parameters. Before comparing RedirectModel instances ensure that they match a given request.
      指定者:
      compareTo 在接口中 Comparable<RedirectModel>
    • equals

      public boolean equals(@Nullable Object other)
      指定者:
      equals 在接口中 Map<String,Object>
      覆盖:
      equals 在类中 AbstractMap<String,Object>
    • hashCode

      public int hashCode()
      指定者:
      hashCode 在接口中 Map<String,Object>
      覆盖:
      hashCode 在类中 AbstractMap<String,Object>
    • toString

      public String toString()
      覆盖:
      toString 在类中 AbstractMap<String,Object>
    • findOutputModel

      @Nullable @Experimental public static RedirectModel findOutputModel(cn.taketoday.core.AttributeAccessor attributeAccessor)
      Return "output" RedirectModel to save attributes for request after redirect.
      参数:
      attributeAccessor - attributeAccessor to use for saving attributes
      返回:
      a RedirectModel instance