在用户登录成功时,将用户存入session中 ------- ActionContext.getContext().getSession().put(YcCommon.User, s);
当在其他页面需要取得当前登录用户信息时,取出session中的用户---
session1 = ServletActionContext.getRequest().getSession();
SaleUser saleUser=(SaleUser) session1.getAttribute(YcCommon.User);
则取不出存入的用户信息
原因:存入时采用的为put 取出时却为getAttribute
修改:存入时应为:ServletActionContext.getRequest().getSession().setAttribute(YcCommon.User, s);