public final class FlashMap extends java.util.HashMap<java.lang.String,java.lang.Object> implements java.lang.Comparable<FlashMap>
A FlashMap can be set up with a request path and request parameters to
help identify the target request. Without this information, a FlashMap is
made available to the next request, which may or may not be the intended
recipient. On a redirect, the target URL is known and a FlashMap can be
updated with that information. This is done automatically when the
org.springframework.web.servlet.view.RedirectView
is used.
Note: annotated controllers will usually not use FlashMap directly.
See org.springframework.web.servlet.mvc.support.RedirectAttributes
for an overview of using flash attributes in annotated controllers.
FlashMapManager
,
Serialized FormConstructor and Description |
---|
FlashMap() |
Modifier and Type | Method and Description |
---|---|
FlashMap |
addTargetRequestParam(java.lang.String name,
java.lang.String value)
Provide a request parameter identifying the request for this FlashMap.
|
FlashMap |
addTargetRequestParams(MultiValueMap<java.lang.String,java.lang.String> params)
Provide request parameters identifying the request for this FlashMap.
|
int |
compareTo(FlashMap other)
Compare two FlashMaps and prefer the one that specifies a target URL
path or has more target URL parameters.
|
boolean |
equals(java.lang.Object other) |
long |
getExpirationTime()
Return the expiration time for the FlashMap or -1 if the expiration
period has not started.
|
MultiValueMap<java.lang.String,java.lang.String> |
getTargetRequestParams()
Return the parameters identifying the target request, or an empty map.
|
java.lang.String |
getTargetRequestPath()
Return the target URL path (or
null if none specified). |
int |
hashCode() |
boolean |
isExpired()
Return whether this instance has expired depending on the amount of
elapsed time since the call to
startExpirationPeriod(int) . |
void |
setExpirationTime(long expirationTime)
Set the expiration time for the FlashMap.
|
void |
setTargetRequestPath(java.lang.String path)
Provide a URL path to help identify the target request for this FlashMap.
|
void |
startExpirationPeriod(int timeToLive)
Start the expiration period for this instance.
|
java.lang.String |
toString() |
public void setTargetRequestPath(java.lang.String path)
The path may be absolute (e.g. "/application/resource") or relative to the current request (e.g. "../resource").
public java.lang.String getTargetRequestPath()
null
if none specified).public FlashMap addTargetRequestParams(MultiValueMap<java.lang.String,java.lang.String> params)
params
- a Map with the names and values of expected parameterspublic FlashMap addTargetRequestParam(java.lang.String name, java.lang.String value)
name
- the expected parameter name (skipped if empty or null
)value
- the expected value (skipped if empty or null
)public MultiValueMap<java.lang.String,java.lang.String> getTargetRequestParams()
public void startExpirationPeriod(int timeToLive)
timeToLive
- the number of seconds before expirationpublic void setExpirationTime(long expirationTime)
startExpirationPeriod(int)
.public long getExpirationTime()
public boolean isExpired()
startExpirationPeriod(int)
.public int compareTo(FlashMap other)
compareTo
in interface java.lang.Comparable<FlashMap>
public boolean equals(java.lang.Object other)
equals
in interface java.util.Map<java.lang.String,java.lang.Object>
equals
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public int hashCode()
hashCode
in interface java.util.Map<java.lang.String,java.lang.Object>
hashCode
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
public java.lang.String toString()
toString
in class java.util.AbstractMap<java.lang.String,java.lang.Object>