JSF 1095 Problem

完整錯誤:

JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash will not be available on the next request.

這會造成 FlashScope 不穩定甚而無法 keep 與 get,解決方法為掛 filter 設置 bufferSize 處理, 以下為程式碼:

@WebFilter("*.xhtml")
public class ResponseBufferSizeFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletResponseWrapper wrapper
                = new HttpServletResponseWrapper((HttpServletResponse) response);
        wrapper.setBufferSize(10000000);
        chain.doFilter(request, wrapper);
    }

    @Override
    public void destroy() {
    }

}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料