Spring MVC: @SessionAttributes shared among controllers?

前端 未结 2 1253
隐瞒了意图╮
隐瞒了意图╮ 2021-01-06 02:29

I have an abstract controller support class for searches and result lists:

@Controller
@SessionAttributes(\"query\")
public abstract class SearchController&l         


        
相关标签:
2条回答
  • 2021-01-06 02:38

    I just tried this on Spring 3.0.2 and the session attributes are not shared between controllers. In fact I was looking for the opposite effect and that's how I found out.

    0 讨论(0)
  • 2021-01-06 02:42

    Using @SessionAttributes this objects will be stored in your HttpSession with the same name and they will be accessible (shared) from different controllers. So, Spring is acting correctly.

    I think the best approach in your scenario is rename this attribute in every subclass ("BookQuery", "AutorQuery", ...). Not very elegant at all :(

    0 讨论(0)
提交回复
热议问题