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

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

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

    紙飛機

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      22 隨筆 :: 28 文章 :: 30 評論 :: 0 Trackbacks

    #

    用jspsmart下載文件異常(tomcat正常,weblogic不行)

    用jspsmart下載文件JSP代碼如下:
    <%@ page contentType="text/html;charset=GBK" import="com.jspsmart.upload.*" %><%
    //取得服務器存放文件的路徑
    String reportTemplatePath = (String)session.getAttribute("reportTemplatePath");
    //文件名
    String filename = reportTemplatePath + "/" + request.getParameter("filename");
    filename = new String(filename.getBytes(),"ISO-8859-1");
    // 新建一個SmartUpload對象
    SmartUpload su = new SmartUpload();
    // 初始化
    su.initialize(pageContext);
    //設定contentDisposition為null以禁止瀏覽器自動打開文件,保證點擊鏈接后是下載文件。若不設定,則下載的文件擴展名為
    //doc時,瀏覽器將自動用word打開它。擴展名為pdf時,瀏覽器將用acrobat打開。
    su.setContentDisposition(null);
    // 下載文件
    su.downloadFile(filename);
    %>在tomcat中運行正常。
    在weblogic中運行拋出如下異常.
    文件可以下載,但特別慢并且打開是亂碼。
    <2004-2-19 下午09時14分34秒> <Error> <HTTP> <101019> <[ServletContext(id=325867,
    name=csrc,context-path=/csrc)] Servlet failed with IOException
    java.net.ProtocolException: Exceeded stated content-length of: '548352' bytes
            at weblogic.servlet.internal.ServletOutputStreamImpl.checkCL(ServletOutp
    utStreamImpl.java:220)
            at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutput
    StreamImpl.java:170)
            at com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:986)
            at com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:355)
            at com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:336)
            at jsp_servlet._test.__do_download._jspService(__do_download.java:102)
            at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
            at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    (ServletStubImpl.java:1058)
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:401)
            at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:306)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run(WebAppServletContext.java:5445)
            at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
    eManager.java:780)
            at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:3105)
            at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2588)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    >

    解決方法:把所有<%和%>之外的空格字符都取掉就好了.參考如下:
    <%@ page contentType="text/html;charset=GBK" import="com.jspsmart.upload.*" %><%
    //取得服務器存放文件的路徑
    String reportTemplatePath = (String)session.getAttribute("reportTemplatePath");
    //文件名
    String filename = reportTemplatePath + "/" + request.getParameter("filename");
    filename = new String(filename.getBytes(),"ISO-8859-1");
    // 新建一個SmartUpload對象
    SmartUpload su = new SmartUpload();
    // 初始化
    su.initialize(pageContext);
    //設定contentDisposition為null以禁止瀏覽器自動打開文件,保證點擊鏈接后是下載文件。若不設定,則下載的文件擴展名為
    //doc時,瀏覽器將自動用word打開它。擴展名為pdf時,瀏覽器將用acrobat打開。
    su.setContentDisposition(null);
    // 下載文件
    su.downloadFile(filename);
    %>

     

    posted @ 2008-06-02 16:04 紙飛機 閱讀(3806) | 評論 (2)編輯 收藏

    GBK的文字編碼是雙字節來表示的,即不論中、英文字符均使用雙字節來表示,只不過為區分中文,將其最高位都定成1。

    至于UTF-8編碼則是用以解決國際上字符的一種多字節編碼,它對英文使用8位(即一個字節),中文使用24位(三個字節)來編碼。對于英文字符較多的論壇則用UTF-8節省空間。

    GBK包含全部中文字符,
    UTF-8則包含全世界所有國家需要用到的字符。

    GBK是在國家標準GB2312基礎上擴容后兼容GB2312的標準(好像還不是國家標準)

    UTF-8編碼的文字可以在各國各種支持UTF8字符集的瀏覽器上顯示。
    比如,如果是UTF8編碼,則在外國人的英文IE上也能顯示中文,而無需他們下載IE的中文語言支持包。

    所以,對于英文比較多的論壇 ,使用GBK則每個字符占用2個字節,而使用UTF-8英文卻只占一個字節。

    請注意:UTF-8版本雖然具有良好的國際兼容性,但中文需要比GBK/BIG5版本多占用50%的數據庫存儲空間,因此并非推薦使用,僅供對國際兼容性有特殊要求的用戶使用。</DIV>
    簡單地說:
           對于中文較多的論壇,適宜用GBK編碼節省數據庫空間。
           對于英文較多的論壇,適宜用UTF-8節省數據庫空間。

    posted @ 2008-05-22 14:07 紙飛機 閱讀(453) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2008-05-15 21:41 紙飛機 閱讀(657) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-26 13:48 紙飛機 閱讀(555) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-26 13:47 紙飛機 閱讀(1458) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-26 13:45 紙飛機 閱讀(317) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-26 13:40 紙飛機 閱讀(359) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-26 13:38 紙飛機 閱讀(708) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-24 23:38 紙飛機 閱讀(298) | 評論 (0)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-10-23 10:10 紙飛機 閱讀(660) | 評論 (0)編輯 收藏

    僅列出標題
    共3頁: 1 2 3 下一頁 
    主站蜘蛛池模板: 在线观看免费大黄网站| 天天影视色香欲综合免费| 免费一级毛片在线观看| 亚洲精品伊人久久久久 | 亚洲第一视频在线观看免费 | 国产亚洲精品看片在线观看| 免费人妻精品一区二区三区| 亚洲福利在线播放| 中国黄色免费网站| 亚洲av日韩av高潮潮喷无码| 久久午夜伦鲁片免费无码| 亚洲伊人久久大香线焦| 成视频年人黄网站免费视频| 亚洲欧洲精品成人久久曰| 国产老女人精品免费视频| 免费毛片毛片网址| 久久综合九九亚洲一区| 国产h视频在线观看网站免费| 亚洲性线免费观看视频成熟| 国产午夜免费秋霞影院| 久久国产乱子伦精品免费午夜 | 麻豆精品成人免费国产片| 久久精品九九亚洲精品| 国产精品视频免费一区二区| 久久久久亚洲国产AV麻豆| 91麻豆国产自产在线观看亚洲| 亚洲精品免费视频| 亚洲欧美一区二区三区日产| 亚洲国产精品国产自在在线 | 亚洲成人黄色在线| 国产精品国产午夜免费福利看 | 亚洲黄片毛片在线观看| 西西人体免费视频| 亚洲五月丁香综合视频| 亚洲精品老司机在线观看| 99久久久国产精品免费牛牛| 亚洲av日韩aⅴ无码色老头 | 日韩va亚洲va欧洲va国产| 97无码免费人妻超级碰碰碰碰| jizz在线免费观看| 亚洲综合色7777情网站777|