<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 1,  comments - 3,  trackbacks - 0
    //設置輸出類容的類型,按照下面設置后flush()才會起作用
    response.setContentType("text/html; charset=UTF-8");
    request.setCharacterEncoding("UTF-8");
    PrintWriter writer = response.getWriter();
    for(int index = 0 ;index < 5 ;index++){
    writer.write("你好!<br />");
    writer.flush();
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) { }
    }
    writer.close();

    /***

    不設置ContentType直接使用flush()不會有作用。

    如果要flush()起作用,必須先向緩沖區(qū)填充一定的內容(測試為1024個字符)。
    網上看到的原因是容器認為緩沖區(qū)的內容過少發(fā)送的效率不高。


    設置了ContentType為text/html后,flush()就會立即起作用。
    可能是因為動態(tài)生成Html的時候加載數據比較耗時,可以先返回后讓瀏覽器解析樣式。(個人猜想)

    上面的內容沒有在任何的官方文檔中看到。唯一在官方文檔中看到和內容大小有關系的是關于Buffer大小的設置:

    setBufferSize

    public void setBufferSize(int size)
    Sets the preferred buffer size for the body of the response. The servlet container will use a buffer at least as large as the size requested. The actual buffer size used can be found using getBufferSize.

    A larger buffer allows more content to be written before anything is actually sent, thus providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.

    This method must be called before any response body content is written; if content has been written or the response object has been committed, this method throws an IllegalStateException.

     

    Parameters:
    size - the preferred buffer size
    Throws:
    java.lang.IllegalStateException - if this method is called after content has been written
    See Also:
    getBufferSize()flushBuffer()isCommitted()reset()

    http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/ServletResponse.html#setBufferSize(int)


    ***/
    posted @ 2016-10-09 18:22 jidebingfeng 閱讀(1280) | 評論 (0)編輯 收藏
    僅列出標題  
    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    文章檔案

    搜索

    •  

    最新評論

    主站蜘蛛池模板: 成人黄页网站免费观看大全| 亚洲AV日韩精品久久久久| 无码国产精品一区二区免费3p| 亚洲6080yy久久无码产自国产| 亚洲成在人天堂在线| 免费人成网站在线播放| 日韩中文字幕精品免费一区| 国产成人免费AV在线播放 | 免费人成网上在线观看| 亚洲区视频在线观看| 亚洲αv在线精品糸列| 亚洲国产一区视频| 日本特黄a级高清免费大片| 91免费播放人人爽人人快乐| 免费成人高清在线视频| 一级做a爰性色毛片免费| 亚洲精品第一国产综合亚AV| 亚洲午夜国产精品无卡| 亚洲人成电影福利在线播放| 久久久久久久亚洲精品| 亚洲精品成人区在线观看| 日韩黄色免费观看| 嫩草影院免费观看| 成人人观看的免费毛片| 精品熟女少妇AV免费观看| 无码国产精品一区二区免费虚拟VR | 亚洲另类无码专区首页| 亚洲午夜久久久精品电影院| 内射干少妇亚洲69XXX| 久久久久亚洲av无码尤物| 亚洲av永久无码精品网站| 精品亚洲综合久久中文字幕| 国产亚洲综合一区柠檬导航| 亚洲国产一区二区三区| 亚洲国产日韩在线观频| 亚洲A∨精品一区二区三区| 免费又黄又硬又爽大片| 一级毛片直播亚洲| 国产亚洲精品AA片在线观看不加载| 亚洲日韩人妻第一页| 在线观看午夜亚洲一区|