public class FacesUtil { public static HttpServletResponse getResponse(){ /** * JSF获取response * @return */ FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.responseComplete(); HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); facesContext.responseComplete(); return response; } public static HttpServletRequest getRequest(){ /** * JSF获取request * @return */ FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.responseComplete(); HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); facesContext.responseComplete(); return request; } }