日期:2014-05-20  浏览次数:20617 次

struts2关于session问题
我在action中
ActionContext.getContext().getSession().put(“”,“”)设置session,
问题是如何设置session持续时间
有没有servlet中的那个方法可以调用?

------解决方案--------------------
方法一:
在使用了struts2框架的任何地方使用
ServletActionContext.getRequest().getSession().setMaxInactiveInterval(xxx);

方法二:
在Action中定义一个HttpServletRequest的成员对象req;
Action类实现ServletRequestAware接口,实现其中的方法;
在实现的方法中编写: req=方法参数;
然后在该Action中任何需要用到Session的地方使用req.getSession()......
------解决方案--------------------
探讨

方法一:
在使用了struts2框架的任何地方使用
ServletActionContext.getRequest().getSession().setMaxInactiveInterval(xxx);

方法二:
在Action中定义一个HttpServletRequest的成员对象req;
Action类实现ServletRequestAware接口,实现其中的方法;
在实现的……

------解决方案--------------------
探讨

方法一:
在使用了struts2框架的任何地方使用
ServletActionContext.getRequest().getSession().setMaxInactiveInterval(xxx);

方法二:
在Action中定义一个HttpServletRequest的成员对象req;
Action类实现ServletRequestAware接口,实现其中的方法;
在实现的……

------解决方案--------------------
http://zhanjun.iteye.com/blog/1065954