- Mastering Spring 5.0
- Ranga Rao Karanam
- 56字
- 2021-07-02 22:12:17
Reading an attribute from the session
This value can be accessed in other controllers by first specifying the @SessionAttributes annotation at a type level:
@Controller
@SessionAttributes("exampleSessionAttribute")
public class SomeOtherController {
The value of the session attribute will be directly made available to all model objects. So, it can be accessed from the model:
Value sessionValue =(Value)model.get("exampleSessionAttribute");