How to update session attribute

前端 未结 2 647
眼角桃花
眼角桃花 2021-02-10 02:40

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:13

    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:19

    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)
提交回复
热议问题