How to update session attribute

前端 未结 2 638
深忆病人
深忆病人 2021-02-10 02:25

I have some session attributes being saved. I have a jsp page on which a call to a servlet is made through. This servlet updates one of the session variable but I am not able to

相关标签:
2条回答
  • 2021-02-10 03:03

    To access the abc variable in the JSP try:

    ${sessionScope.abc}
    

    Also note that removing before setting is usually redundant. So:

    request.getSession().removeAttribute("abc");
    request.getSession().setAttribute("abc", abc);
    

    Can simply become:

    request.getSession().setAttribute("abc", abc);
    
    0 讨论(0)
  • 2021-02-10 03:07

    I had similar problem. It turned out that when you use

    HttpSession 
    

    object in your controller, it shouldn't be annotated using

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