有两种方法可以访问session, 通过ActionContext或者实现SessionAware接口,第二种是推荐的。
1. 通过ActionContext
Map attributes = ActionContext.getContext().getSession();
2. 实现SessionAware接口
首先使Action implements SessionAware
然后 Map parameters = this.getSession();
任何对parameters的改动都会直接影响session.