Session attributes

All the attributes and values that we discussed until now are used within a single request. However, there might be values such as a specific web user configuration that might not change across requests. These kinds of values will typically be stored in an HTTP session. Spring MVC provides a simple type level (class level) annotation @SessionAttributes to specify the attributes that would be stored in the session.

Take a look at the following example:

    @Controller     @SessionAttributes("exampleSessionAttribute")     public class LoginController {

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.