类 SessionAttributesHandler
java.lang.Object
cn.taketoday.web.handler.method.SessionAttributesHandler
Manages controller-specific session attributes declared via
@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().
- 从以下版本开始:
- 4.0 2022/4/8 23:18
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Harry Yang
-
字段概要
字段 -
构造器概要
构造器构造器说明SessionAttributesHandler(Class<?> handlerType, SessionAttributeStore sessionAttributeStore) Create a new session attributes handler. -
方法概要
修饰符和类型方法说明voidcleanupAttributes(RequestContext request) Remove "known" attributes from the session, i.e. attributes listed by name in@SessionAttributesor attributes previously stored in the model that matched by type.booleanWhether the controller represented by this instance has declared any session attributes through anSessionAttributesannotation.booleanisHandlerSessionAttribute(String attributeName, Class<?> attributeType) Whether the attribute name or type match the names and types specified via@SessionAttributeson the underlying controller.(专用程序包) ObjectretrieveAttribute(RequestContext request, String attributeName) A pass-through call to the underlyingSessionAttributeStore.retrieveAttributes(RequestContext request) Retrieve "known" attributes from the session, i.e. attributes listed by name in@SessionAttributesor attributes previously stored in the model that matched by type.voidstoreAttributes(RequestContext request, Map<String, ?> attributes) Store a subset of the given attributes in the session.
-
字段详细资料
-
attributeNames
-
attributeTypes
-
knownAttributeNames
-
sessionAttributeStore
-
-
构造器详细资料
-
SessionAttributesHandler
Create a new session attributes handler. Session attribute names and types are extracted from the@SessionAttributesannotation, if present, on the given type.- 参数:
handlerType- the controller typesessionAttributeStore- used for session access
-
-
方法详细资料
-
hasSessionAttributes
public boolean hasSessionAttributes()Whether the controller represented by this instance has declared any session attributes through anSessionAttributesannotation. -
isHandlerSessionAttribute
Whether the attribute name or type match the names and types specified via@SessionAttributeson the underlying controller.Attributes successfully resolved through this method are "remembered" and subsequently used in
retrieveAttributes(RequestContext)andcleanupAttributes(RequestContext).- 参数:
attributeName- the attribute name to checkattributeType- the type for the attribute
-
storeAttributes
Store a subset of the given attributes in the session. Attributes not declared as session attributes via@SessionAttributesare ignored.- 参数:
request- the current requestattributes- candidate attributes for session storage
-
retrieveAttributes
Retrieve "known" attributes from the session, i.e. attributes listed by name in@SessionAttributesor attributes previously stored in the model that matched by type.- 参数:
request- the current request- 返回:
- a map with handler session attributes, possibly empty
-
cleanupAttributes
Remove "known" attributes from the session, i.e. attributes listed by name in@SessionAttributesor attributes previously stored in the model that matched by type.- 参数:
request- the current request
-
retrieveAttribute
A pass-through call to the underlyingSessionAttributeStore.- 参数:
request- the current requestattributeName- the name of the attribute of interest- 返回:
- the attribute value, or
nullif none
-