有兩種方法可以訪問session,通過ActionContext或者實現SessionAware接口,第二種是推薦的。
1.通過ActionContext
Map attributes = ActionContext.getContext().getSession();
2.實現SessionAware接口
首先使Action implements SessionAware
然後 Map parameters = this.getSession();
任何對parameters的改動都會直接影響session.