JSF2中取得HttpServletRequest和HttpSession

在JSF2中取得HttpServletRequest和HttpSession:

FacesContext facesContext = FacesContext.getCurrentInstance();
        
ExternalContext externalContext = facesContext.getExternalContext();
        //取得HttpServletRequest
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
        //取得HttpSession
HttpSession session =(HttpSession) externalContext.getSession(true);

 

你可能感兴趣的:(JSF2中取得HttpServletRequest和HttpSession)