<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

    2007年7月9日 #

    用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)編輯 收藏

    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)編輯 收藏

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

         摘要:   閱讀全文
    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)編輯 收藏

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

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

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

         摘要:   閱讀全文
    posted @ 2007-07-20 15:44 紙飛機 閱讀(5179) | 評論 (2)編輯 收藏

         摘要:   閱讀全文
    posted @ 2007-07-19 22:41 紙飛機 閱讀(2051) | 評論 (3)編輯 收藏

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

    最近在學習Hibernate這個框架,有找到一個比較好的資料,作者的blog名是分享Java快樂
    website:http://blog.csdn.net/javamxj/
    我有將其資料制作成chm電子檔,這樣學習起來比較方便,需要的朋友可通過如下鏈接下載:

     http://www.tkk7.com/Files/jxhkwhy/Eclipse快速上手Hibernate.rar

    另以上的例子我都有重新做過一遍,期間也碰到不過問題,如果學習的朋友碰到問題可找我,我一定會盡力回復!

     

    posted @ 2007-07-09 00:22 紙飛機 閱讀(1233) | 評論 (5)編輯 收藏

    主站蜘蛛池模板: 亚洲不卡在线观看| 亚洲理论精品午夜电影| 久久亚洲中文字幕无码| 四虎成人免费影院网址| 欧美亚洲国产SUV| 国产黄色片在线免费观看| 午夜亚洲WWW湿好爽| 亚洲成年人啊啊aa在线观看| 羞羞视频免费观看| 亚洲国产成人乱码精品女人久久久不卡 | 日韩亚洲国产综合久久久| 国产亚洲精品免费| 亚洲国产小视频精品久久久三级| 免费在线观看自拍性爱视频| 内射无码专区久久亚洲| 你是我的城池营垒免费看| 午夜亚洲AV日韩AV无码大全| 永久黄色免费网站| 色天使亚洲综合在线观看| 亚洲AV中文无码乱人伦下载| 精品国产麻豆免费人成网站| 亚洲高清在线mv| 宅男666在线永久免费观看| 污视频网站免费在线观看| 国产亚洲美女精品久久久2020| 三年片免费观看大全国语| 亚洲高清视频免费| 日韩免费电影在线观看| 黄床大片免费30分钟国产精品| 香蕉视频在线观看亚洲| 德国女人一级毛片免费 | 久草免费福利在线| 少妇中文字幕乱码亚洲影视| 67194成是人免费无码| 成年网站免费入口在线观看 | 97在线免费视频| 久久亚洲精品专区蓝色区| 亚洲片国产一区一级在线观看| 亚洲国产精品免费视频| 色九月亚洲综合网| 亚洲美女aⅴ久久久91|