<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()起作用,必須先向緩沖區填充一定的內容(測試為1024個字符)。
    網上看到的原因是容器認為緩沖區的內容過少發送的效率不高。


    設置了ContentType為text/html后,flush()就會立即起作用。
    可能是因為動態生成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 閱讀(1274) | 評論 (0)編輯 收藏
    <2016年10月>
    2526272829301
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    文章檔案

    搜索

    •  

    最新評論

    主站蜘蛛池模板: a级片免费在线观看| 久久精品国产亚洲av天美18| 成人av片无码免费天天看| 免费国产精品视频| 麻豆va在线精品免费播放| 免费人成视频x8x8入口| 日产久久强奸免费的看| 亚洲精品视频在线看| 丝袜足液精子免费视频| 亚洲AV日韩精品久久久久久久| 久9久9精品免费观看| 亚洲综合色丁香麻豆| 日本三级2019在线观看免费| 色天使亚洲综合在线观看| 暖暖在线日本免费中文| 最好2018中文免费视频| 亚洲精品国产字幕久久不卡| 1区2区3区产品乱码免费| 亚洲熟妇自偷自拍另欧美| 国产成人免费网站在线观看| 丰满人妻一区二区三区免费视频| 亚洲天堂在线播放| 大陆一级毛片免费视频观看| 日本黄页网址在线看免费不卡| 亚洲精品成人片在线播放| 麻豆一区二区免费播放网站| 国产亚洲精品国产福利在线观看| 亚洲午夜久久久久妓女影院| 久久久久久精品免费看SSS| 国产精品亚洲天堂| 亚洲AV无码精品色午夜果冻不卡| 4hu四虎最新免费地址| 国产亚洲精品美女久久久久 | 中文字幕手机在线免费看电影| 亚洲不卡中文字幕无码| 无码人妻一区二区三区免费| 一级毛片免费不卡| 亚洲成综合人影院在院播放| 亚洲AV成人潮喷综合网| 免费观看无遮挡www的视频| 免费高清A级毛片在线播放|