@SessionAttribute
If you need access to pre-existing session attributes that are managed globally
(that is, outside the controller — for example, by a filter) and may or may not be present,
you can use the @SessionAttribute
annotation on a method parameter,
as the following example shows:
-
Java
@RequestMapping("/")
public String handle(@SessionAttribute User user) { (1)
// ...
}
1 | Using a @SessionAttribute annotation. |