@Target([AnnotationTarget.VALUE_PARAMETER]) class SessionAttribute
Annotation to bind a method parameter to a session attribute.
The main motivation is to provide convenient access to existing, permanent session attributes (e.g. user authentication object) with an optional/required check and a cast to the target method parameter type.
For use cases that require adding or removing session attributes consider injecting org.springframework.web.context.request.WebRequest or javax.servlet.http.HttpSession into the controller method.
For temporary storage of model attributes in the session as part of the workflow for a controller, consider using SessionAttributes instead.
Author
Rossen Stoyanchev
Since
4.3
See Also
RequestMappingSessionAttributesRequestAttribute
SessionAttribute(value: String, name: String, required: Boolean)
Annotation to bind a method parameter to a session attribute. The main motivation is to provide convenient access to existing, permanent session attributes (e.g. user authentication object) with an optional/required check and a cast to the target method parameter type. For use cases that require adding or removing session attributes consider injecting For temporary storage of model attributes in the session as part of the workflow for a controller, consider using SessionAttributes instead. |
val name: String
The name of the session attribute to bind to. The default name is inferred from the method parameter name. |
|
val required: Boolean
Whether the session attribute is required. Defaults to |
|
val value: String
Alias for |