Sitemesh装饰器页面如何获得session中对象?

使用sitemesh装饰全部页面,在页面上显示session中当前用户信息,但是使用EL表达式${session.loginUser}获取session中对象失败。
如何可以在装饰页面获取session中对象呢?

  1. 你的el语法问题: ${sessionScope.loginUser}

el 中的 scop:
pageScope
requestScope
sessionScope

  1. 如果语法对的,检查后台是不是放错了:

后台用是 Struts 2, 估计你放错Session了。
Struts 2 提供的 session 在ValueStack 上, 不是传统的 HttpServletSession

这么取你的session:
[code="java"]
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession(true);

session.setAttribute("loginUser", "lvjian700");
[/code]

是获取Session失败还是LoginUser失败?