阅读背景:

在struts2 中通过ActionContext访问Session对象

来源:互联网 
通过com.opensymphony.xwork2.ActionContext取
如先获取request
HttpServletRequest request = (HttpServletRequest)ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_RESPONSE);
那么取session就和struts1一样了
HttpSession session = request.getSession();

操作都一样的

另外在action 内往session中保存数据,可以直接用下面的方法:
ActionContext.getContext().getSession().put(key, value)
key object型
value object型
通过com.opensymphony.xwork2.ActionContext取
如先获取re



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: