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");

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.