application、session、request、cookie

来源:互联网 发布:windows高级编程 pdf 编辑:程序博客网 时间:2024/05/17 02:43

一、application

1、托管Bean里

a、

 ExternalContext ect=FacesContext.getCurrentInstance().getExternalContext() ect.getApplicationMap().get("ug"); ect.getApplicationMap().put("ug","123");

b、

 ServletContext application = session.getServletContext() application.getAttribute("ugm");

2、普通javaBean里

 同1.1.b   1.1.a不行,取不到application



二、session

1、托管Bean里

 ExternalContext ect=FacesContext.getCurrentInstance().getExternalContext() HttpSession session = (HttpSession) ect.getSession(true); session.getAttribute("ugm");

2、普通javaBean里

 同2.1