struts2 中在action中设置的session 如何在jsp页面中获取

我在登录判断页面设置了session 值ActionContext.getContext().getSession().put("username",user.getUsername());
ActionContext.getContext().getSession().put("user",user);

ActionContext.getContext().getSession().put("realname",user.getRealname());

ServletActionContext.getRequest().getSession().setAttribute("kmid",user.getKmid());
然后在后台页面 通过<%=session.getAttribute("realname")%><%=session.getAttribute("username")%>只能获的username的值 也就是说 在登录界面登录框内的值 都能获取,其他的则不行。怎么解决?请高手指点

第1个回答  2012-04-12
没必要那么麻烦 你只要放一个user就可以了
其他那几个 我看都是user的属性
你在页面获取user以后,在get获取他的属性就可以了
没必要每个属性都放到session中 都写一遍本回答被提问者采纳
第2个回答  2012-04-12
把user对象得到后在页面上用user.对象属性值就可以获取了
第3个回答  2012-04-12
你用<s:debug></s:debug>,看看值栈中有没有,再通过标签取
第4个回答  2012-04-12
其他的值你确定都有值么 ?? 在通过action的时候 你先打印出来 看是不是有那些值!!!
相似回答