Problem with session attributes in JSP EL using Spring MVC

后端 未结 3 818
-上瘾入骨i
-上瘾入骨i 2020-12-16 20:38

I\'m trying to show a session attribute \"userSession\" in a jsp page using JSP EL, but it returns null (case 1). Request attributes are shown properly in EL expressions tho

相关标签:
3条回答
  • 2020-12-16 20:52

    What does:

    <c:out value="${sessionScope.userSession}"/>
    

    or

    <c:out value="${sessionScope['userSession']}"/>
    

    give?

    0 讨论(0)
  • 2020-12-16 21:02

    Fixed. Problem was with a <%@ page session="false" %> directive found in an include.jsp used by my page, which I removed from that global place.

    It prevents a jsp page from access to session scope variables. So only <%=request.getSession().getAttribute("foo")%> works in that case...

    0 讨论(0)
  • <c:out value="${sessionScope}"/> or just ${sessionScope} list all the attributes in portlet application scope.

    so, You can try to get your attribut with this expression !

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