+ -
当前位置:首页 → 问答吧 → struts2关于session问题

struts2关于session问题

时间:2011-11-30

来源:互联网

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

作者: godiii   发布时间: 2011-11-30

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

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

作者: vincent_3951   发布时间: 2011-11-30