@SessionAttributes. Actual storage is
delegated to a SessionAttributeStore instance.
When a controller annotated with @SessionAttributes adds
attributes to its model, those attributes are checked against names and
types specified via @SessionAttributes. Matching model attributes
are saved in the HTTP session and remain there until the controller calls
SessionStatus#setComplete().
| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private final Set | |
| private final Set | |
| public static final String | SESSION_KNOWN_ATTRIBUTE
Key for known-attribute-names storage (a String array) as a session attribute. |
| private final SessionAttributeStore |
| Access | Constructor and Description |
|---|---|
| public | SessionAttributesHandler(Class<?>
the controller type handlerType, SessionAttributeStore used for session access sessionAttributeStore)Create a new session attributes handler. |
| Modifier and Type | Method and Description |
|---|---|
| public void | cleanupAttributes(WebRequest
the current request request)Remove "known" attributes from the session, i.e. attributes listed
by name in |
| public boolean | hasSessionAttributes()
Whether the controller represented by this instance has declared any
session attributes through an |
| public boolean | isHandlerSessionAttribute(String
the attribute name to check attributeName, Class<?> the type for the attribute attributeType)Whether the attribute name or type match the names and types specified
via |
| pack-priv Object | Returns: the attribute value, ornull if nonethe current request request, String the name of the attribute of interest attributeName)A pass-through call to the underlying |
| public Map | Returns: a map with handler session attributes, possibly emptythe current request request)Retrieve "known" attributes from the session, i.e. attributes listed
by name in |
| public void | storeAttributes(WebRequest
the current request request, Map<String, ?> candidate attributes for session storage attributes)Store a subset of the given attributes in the session. |
| attributeNames | back to summary |
|---|---|
| private final Set<String> attributeNames | |
| attributeTypes | back to summary |
|---|---|
| private final Set<Class<?>> attributeTypes | |
| knownAttributeNames | back to summary |
|---|---|
| private final Set<String> knownAttributeNames | |
| SESSION_KNOWN_ATTRIBUTE | back to summary |
|---|---|
| public static final String SESSION_KNOWN_ATTRIBUTE Key for known-attribute-names storage (a String array) as a session attribute. This is necessary for consistent handling of type-based session attributes in distributed session scenarios where handler methods from the same class may get invoked on different servers.
| |
| sessionAttributeStore | back to summary |
|---|---|
| private final SessionAttributeStore sessionAttributeStore | |
| SessionAttributesHandler | back to summary |
|---|---|
| public SessionAttributesHandler(Class<?> handlerType, SessionAttributeStore sessionAttributeStore) Create a new session attributes handler. Session attribute names and types
are extracted from the
| |
| cleanupAttributes | back to summary |
|---|---|
| public void cleanupAttributes(WebRequest request) Remove "known" attributes from the session, i.e. attributes listed
by name in
| |
| hasSessionAttributes | back to summary |
|---|---|
| public boolean hasSessionAttributes() Whether the controller represented by this instance has declared any
session attributes through an | |
| isHandlerSessionAttribute | back to summary |
|---|---|
| public boolean isHandlerSessionAttribute(String attributeName, Class<?> attributeType) Whether the attribute name or type match the names and types specified
via Attributes successfully resolved through this method are "remembered"
and subsequently used in | |
| retrieveAttribute | back to summary |
|---|---|
| pack-priv Object retrieveAttribute(WebRequest request, String attributeName) A pass-through call to the underlying
| |
| retrieveAttributes | back to summary |
|---|---|
| public Map Retrieve "known" attributes from the session, i.e. attributes listed
by name in
| |
| storeAttributes | back to summary |
|---|---|
| public void storeAttributes(WebRequest request, Map<String, ?> attributes) Store a subset of the given attributes in the session. Attributes not
declared as session attributes via
| |