Spring MVC @SessionAttribute:如何从会话中删除属性

时间:2014-03-17 01:48:56

标签: session spring-mvc attributes

我使用@SessionAttribute(“myForm”)将myForm存储在会话中。我可以毫无问题地从会话中获取myForm。但是当我试图从会话中删除myForm时,看起来我无法使用removeAttribute(“myForm”)删除它。

    MyForm myForm = (MyForm)request.getSession().removeAttribute("myForm");
    if(myForm != null){
          request.getSession().removeAttribute("myForm"); 
     }
     //get myForm again to check if it has been removed.
     myForm = (MyForm)request.getSession().removeAttribute("myForm");
     //Check it again and the myForm IS NOT NULL after removal.

我不确定它有什么问题。任何问题? 提前谢谢。

0 个答案:

没有答案