@SessionAttribute annotation

@SessionAttribute annotation usage

The @SessionAttributes annotation can only be used on the definition of a class. The source code of this annotation is shown below

Insert picture description here

@SessionAttributes(types={User.class, Dept.class}) will add all attributes of type User and Dept in the model to the session, that is, the session scope.

@SessionAttributes(value={"user1", "user2"}) will add the attributes named user1 and user2 in the model to the session, that is, the session scope.

The variable name or variable type modified with @SessionAttributes will be added to the session scope at the same time as the request scope. Note that it is not only added to the session scope, remember to remember.

Insert picture description here

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45950109/article/details/110826448