<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
    //設(shè)置輸出類容的類型,按照下面設(shè)置后flush()才會(huì)起作用
    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();

    /***

    不設(shè)置ContentType直接使用flush()不會(huì)有作用。

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


    設(shè)置了ContentType為text/html后,flush()就會(huì)立即起作用。
    可能是因?yàn)閯?dòng)態(tài)生成Html的時(shí)候加載數(shù)據(jù)比較耗時(shí),可以先返回后讓瀏覽器解析樣式。(個(gè)人猜想)

    上面的內(nèi)容沒(méi)有在任何的官方文檔中看到。唯一在官方文檔中看到和內(nèi)容大小有關(guān)系的是關(guān)于Buffer大小的設(shè)置:

    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 閱讀(1274) | 評(píng)論 (0)編輯 收藏
    僅列出標(biāo)題  
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    文章檔案

    搜索

    •  

    最新評(píng)論

    主站蜘蛛池模板: 大胆亚洲人体视频| 日韩吃奶摸下AA片免费观看| 久久亚洲中文字幕精品一区| 欧洲精品码一区二区三区免费看| 国产亚洲精品免费| 日韩亚洲综合精品国产| 亚洲VA综合VA国产产VA中| 丁香六月婷婷精品免费观看| 亚洲精品成人久久久| 久久er国产精品免费观看8| 国产亚洲精品无码拍拍拍色欲| 精品免费久久久久国产一区| 亚洲AV无码乱码国产麻豆穿越| 国产精品99久久免费观看| 亚洲人成免费网站| 成年女人毛片免费观看97| 免费的黄色的网站| 亚洲乱码精品久久久久..| 色欲A∨无码蜜臀AV免费播| 亚洲AV无码乱码在线观看代蜜桃| 午夜dj在线观看免费视频| 九九久久精品国产免费看小说| 亚洲av日韩av不卡在线观看| 国产精品成人免费一区二区 | 国产成人免费在线| 亚洲性色AV日韩在线观看| 免费国产成人高清视频网站| 三上悠亚在线观看免费| 亚洲综合久久成人69| 免费无码成人AV片在线在线播放| 一级成人生活片免费看| 91亚洲性爱在线视频| 国产91久久久久久久免费| 久久青草免费91观看| 亚洲日本在线电影| 亚洲爆乳精品无码一区二区三区| 亚洲免费福利在线视频| 亚欧洲精品在线视频免费观看| 91在线亚洲精品专区| 四虎精品亚洲一区二区三区| 欧洲精品99毛片免费高清观看 |