作用域相关问题

所有空间

产品规划
AOM百科
知识共享

导航
目录

FAQ

@SaveState的用法

@SaveState声明一个域的状态需要被保存。inServer属性表示是否将此域保存到服务器中(false表示保存到客户端),如果inServer为true则保存到SESSION中。@SaveState 一般用在REQUEST的LiteBean中。用法如下:

   @SaveState 
   private int count = 0;

如何销毁session

SessionBean.java
   FacesContext context = FacesContext.getCurrentInstance();
   HttpSession session = (HttpSession)context.getExternalContext().getSession(false);
   session.invalidate();

AOM存取session的两种方法

第一种
   FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key, value);
   FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(key);
第二种
   HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
   session.setAttribute(name, value);
   session.getAttribute(name);
输入标签加入到本页面中
Please wait 
寻找标签吗?请输入搜索信息.