1:
Java代码
ActionContext.getContext().getSession()
ActionContext.getContext().getSession()
这个方法获得的不是HttpSession对象,而是一个Map对象。
要存值进去或者取值需要用以下方法
2:用法
Java代码
ActionContext.getContext().getSession().put("validateCode", s);
ActionContext.getContext().getSession().get("validateCode")
ActionContext.getContext().getSession().put("validateCode", s);
ActionContext.getContext().getSession().get("validateCode")
以上方法和session.setAttribute();session.getAttribute();的作用相同,并且可以混用
Java代码
ActionContext.getContext().getSession()
ActionContext.getContext().getSession()
这个方法获得的不是HttpSession对象,而是一个Map对象。
要存值进去或者取值需要用以下方法
2:用法
Java代码
ActionContext.getContext().getSession().put("validateCode", s);
ActionContext.getContext().getSession().get("validateCode")
ActionContext.getContext().getSession().put("validateCode", s);
ActionContext.getContext().getSession().get("validateCode")
以上方法和session.setAttribute();session.getAttribute();的作用相同,并且可以混用
本文介绍了如何使用Struts框架中的ActionContext获取并管理Session。通过ActionContext.getContext().getSession()方法可以获得一个Map对象来代替传统的HttpSession,从而实现Session数据的存取操作。
760

被折叠的 条评论
为什么被折叠?



