Session 其他的范围对象的得到方式

1.第一种方式:ActionContext context=ActionContext.getContext();

                           Map<String,Object> map=context.getSesssion();

                          map.put("phone",this.entity.getPhone());

   第二种方式:(特别灵活):

                        HttpSession sesssion=ServletActionContext.getRequest().getSession();

                        Session.getAttribute("phone", this.entity.getPhone());

 第三种方式:第一步要实现sessionAware,会话感知接口

                        第二步重写setSession方法,该方法的参数是一个Map<String,Object>,向该对象中写入数据,就相当于向session中写入数据了 

猜你喜欢

转载自blog.csdn.net/ke_new/article/details/78648073