一、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
本文深入解析JSBean在使用Application和Session时的交互机制,详细讲解如何在托管Bean和普通JavaBean中获取并设置应用和会话属性。
181

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



