struts2 的一个问题,在线等。。。。

来源:百度知道 编辑:UC知道 时间:2024/06/17 20:46:42
我在struts2中的action中ActionContext.getContext().getSession().put("username", this.getUsername());

在jsp页面中用jstl
<c:if test="${empty username} " >
<c:redirect url="login.jsp"/>
</c:if>
为什么不起作用呢

<s:if test="${empty session['username']} " >
<c:redirect url="login.jsp"/>
</s:if>
<s:else>
bbb
</s:else>

OGNL表达式可以直接去VALUESTACK取SESSION的值。比如session['username']