Spring Framework 3 and session attributes

前端 未结 5 964
你的背包
你的背包 2020-12-02 14:45

I have form object that I set to request in GET request handler in my Spring controller. First time user enters to page, a new form object should be made and set to request.

5条回答
  •  天涯浪人
    2020-12-02 15:10

    I'm struggling with this as well. I read this post and it made some things clearer:

    Set session variable spring mvc 3

    As far as I understood it this basically says:

    • that Spring puts the objects specified by @SessionAttributes into the session only for the duration between the first GET request and the POST request that comes after it. After that the object is removed from the session. I tried it in a small application and it approved the statement.

    So if you want to have objects that last longer throughout multiple GET and POST requests you will have to add them manually to the HttpSession, as usual.

提交回复
热议问题