当前位置: 首页 > 工具软件 > Response JS > 使用案例 >

JSF创建response和request

郑鸿朗
2023-12-01
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;
    }
}
 类似资料: