1)在LogonAction的execute方法添加:
ActionContext.getContext().getSession().put("username", getUsername());
ActionContext
+getSession()
注意:返回的不是HttpSession,而是一个Map的封装,
Struts2.x框架的内置拦截器实现了Session和HttpSession之间的转换
如:
Map userlist = (Map) ActionContext.getContext().get("session").put("username",getUsername());
2)在目标页面successful.jsp添加
${username }
输出该Session中key为"username"的值