|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> java.util.HashMap<java.lang.String,java.lang.Object> org.springframework.web.servlet.FlashMap
public final class FlashMap
A FlashMap provides a way for one request to store attributes intended for use in another. This is most commonly needed when redirecting from one URL to another -- e.g. the Post/Redirect/Get pattern. A FlashMap is saved before the redirect (typically in the session) and is made available after the redirect and removed immediately.
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 for example
org.springframework.web.servlet.view.RedirectView
has the
opportunity to automatically update the current FlashMap with target
URL information.
Annotated controllers will usually not use this type directly.
See org.springframework.web.servlet.mvc.support.RedirectAttributes
for an overview of using flash attributes in annotated controllers.
FlashMapManager
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Field Summary | |
---|---|
private int |
createdBy
|
private long |
expirationStartTime
|
private static long |
serialVersionUID
|
private MultiValueMap<java.lang.String,java.lang.String> |
targetRequestParams
|
private java.lang.String |
targetRequestPath
|
private int |
timeToLive
|
Constructor Summary | |
---|---|
FlashMap()
Create a new instance. |
|
FlashMap(int createdBy)
Create a new instance with an id uniquely identifying the creator of this FlashMap. |
Method Summary | |
---|---|
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. |
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 . |
boolean |
isCreatedBy(int createdBy)
Whether the given id matches the id of the creator of this FlashMap. |
boolean |
isExpired()
Whether this instance has expired depending on the amount of elapsed time since the call to startExpirationPeriod(int) . |
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()
|
Methods inherited from class java.util.HashMap |
---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Field Detail |
---|
private static final long serialVersionUID
private java.lang.String targetRequestPath
private final MultiValueMap<java.lang.String,java.lang.String> targetRequestParams
private long expirationStartTime
private int timeToLive
private final int createdBy
Constructor Detail |
---|
public FlashMap(int createdBy)
public FlashMap()
Method Detail |
---|
public void setTargetRequestPath(java.lang.String path)
path
- the URI pathpublic java.lang.String getTargetRequestPath()
null
.
public FlashMap addTargetRequestParams(MultiValueMap<java.lang.String,java.lang.String> params)
params
- a Map with the names and values of expected parameters.public FlashMap addTargetRequestParam(java.lang.String name, java.lang.String value)
name
- the expected parameter name, skipped if null
value
- the expected parameter value, skipped if null
public MultiValueMap<java.lang.String,java.lang.String> getTargetRequestParams()
public void startExpirationPeriod(int timeToLive)
timeToLive
- the number of seconds before expirationpublic boolean isExpired()
startExpirationPeriod(int)
.
public boolean isCreatedBy(int createdBy)
public int compareTo(FlashMap other)
compareTo
in interface java.lang.Comparable<FlashMap>
public java.lang.String toString()
toString
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |