在 servlet 中,请求 / 会话 / 应用程序属性可从doGet(HttpServletRequest request, HttpServletResponse response)
/doPost(HttpServletRequest request, HttpServletResponse response)
方法中获得:
//request attributes
String string = (String)request.getAttribute("username");
//session attributes
String string = (String)request.getSession().getAttribute("username");
//application attributes
String string = (String)getServletContext().getAttribute("beanName");
当请求由 处理时FacesServlet
,属性可用:
//request attributes
String string = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("username");
//session attributes
String string = (String)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("username");
//application attributes
String string = (String)FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("username");
推荐阅读