<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()才會起作用
    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()不會有作用。

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


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

    上面的內(nè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)


    ***/


    @Source:
    @Author:zlong
    posted on 2016-10-09 18:22 jidebingfeng 閱讀(1276) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    <2016年10月>
    2526272829301
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    文章檔案

    搜索

    •  

    最新評論

    主站蜘蛛池模板: 亚洲人成色777777精品| 久久99精品视免费看| 亚洲中文字幕在线乱码| 久久中文字幕免费视频| 亚洲熟妇AV一区二区三区浪潮| 亚洲精品视频免费| 最近2019中文字幕免费直播| 自拍偷自拍亚洲精品播放| 亚洲αv在线精品糸列| 免费观看理论片毛片| 久久国产精品免费看| 亚洲国产午夜精品理论片在线播放| 久久亚洲中文字幕精品一区四| 91免费国产自产地址入| 成人特级毛片69免费观看| 亚洲一级免费视频| 国产成人综合亚洲AV第一页| 毛片免费观看的视频在线| a级毛片免费完整视频| 亚洲av日韩专区在线观看| 久久亚洲AV成人出白浆无码国产| 国产中文字幕免费| 国产曰批免费视频播放免费s| 特级毛片爽www免费版| 亚洲一区二区三区乱码在线欧洲| 亚洲欧洲成人精品香蕉网| 国产免费观看视频| 69堂人成无码免费视频果冻传媒 | 亚洲视频在线观看免费视频| 国产人成免费视频| 久久午夜免费视频| 色欲国产麻豆一精品一AV一免费| 一区二区三区视频免费| 亚洲精品色播一区二区| 亚洲国产模特在线播放| 无码乱人伦一区二区亚洲| 亚洲综合激情另类专区| 国产青草视频在线观看免费影院| 国产一卡2卡3卡4卡无卡免费视频 国产一卡二卡3卡四卡免费 | 国产成人A在线观看视频免费| 男女午夜24式免费视频|