<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

    2008年6月2日 #

    用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 紙飛機 閱讀(3798) | 評論 (2)編輯 收藏

    2008年5月22日 #

    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 紙飛機 閱讀(449) | 評論 (0)編輯 收藏

    2008年5月15日 #

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

    2007年10月26日 #

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

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

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

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

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

    2007年10月24日 #

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

    2007年10月23日 #

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

    僅列出標題  下一頁
    主站蜘蛛池模板: 国产日韩久久免费影院| 亚洲欧美国产欧美色欲| 久久久久久久久久免免费精品| 在线观看国产情趣免费视频| 亚洲人成www在线播放| 色窝窝免费一区二区三区| 亚洲国产精品成人精品软件| 18禁无遮挡无码国产免费网站| 亚洲网站免费观看| 免费h片在线观看网址最新| 亚洲人成人77777在线播放| 性一交一乱一视频免费看| 亚洲av最新在线观看网址| 日韩亚洲国产二区| 久久er国产精品免费观看8| 亚洲AV无码一区东京热| 亚洲精品视频在线免费| 亚洲色欲色欱wwW在线| 亚洲AⅤ优女AV综合久久久| 成人A毛片免费观看网站| 亚洲国产天堂在线观看| 免费中文熟妇在线影片| 免费又黄又爽又猛大片午夜| 亚洲一区无码中文字幕| 59pao成国产成视频永久免费| 亚洲中文字幕一二三四区苍井空| 男女啪啪永久免费观看网站| 少妇亚洲免费精品| 亚洲AV本道一区二区三区四区| 67194熟妇在线永久免费观看| 狠狠入ady亚洲精品| 亚洲精品蜜桃久久久久久| 精品免费人成视频app| 美女18毛片免费视频| 亚洲国产精品自在线一区二区| 午夜两性色视频免费网站| 久久久久国色AV免费观看| 亚洲成a人片在线观看播放| 免费在线观看污网站| 222www免费视频| 一本久久免费视频|