How to pass a session attribute as method argument (parameter) with Spring MVC

Viewed 13724

In short, I want something like:

public String action(@SessionAttribute User user) {..}

instead of

public String action(HttpSession session) {
     User user = session.getAttribute("user");
}

Mainly for the sake of:

  • readability
  • unit testing
3 Answers
Related