在action中将字符串、对象、list集合保存到session中,在jsp页面获取
1:将字符串保存到session中
ServletActionContext.getRequest().getSession().setAttribute("username","leo");
在jsp页面中获取保存在session中的字符串
<s:property value="#session.username" />
2:将对象保存到session中
ServletActionContext.getRequest().getSession().setAttribute("user",user);
在jsp页面中获取保存在session中的对象
<s:property value="#session.user.name" />
3:将list集合保存到session中
ServletActionContext.getRequest().getSession().setAttribute("userList",list);
在jsp页面中获取保存在session中的字符串
<s:iterator value="#session.userList">
<s:property value="id"/>
<s:property value="username"/>