ActionContext获取session
ActionContext.getContext().getSession();
这个方法获取的session是struts封装过的一个Map类型的session,只能调用put()方法缓存数据
ActionContext.getContext().getSession().put("xxx", xxx);
ActionContext
xwork框架的ActionContext是Action执行时的上下文,存放Action执行时需要用到的对象。在使用webwork时,其中放有Parameter、Session、ServletContext、Locale等信息
ServletActionContext获取session
ServletActionContext.getRequest().getSession();
这个方法获取的session是原生的session,可以调用setAttribute()方法
ServletActionContext.getRequest().getSession().setAttribute("xxx", xxx);
ServletActionContext
提供直接与Servlet容器交互的途径;通过它,可以取得HttpServletRequest、HttpServletResponse 、ServletConfig、ServletContext、PageContext 对象