afunms

          My Software,My Dream—Forge a more perfect NMS product.

          解決從tomcat移植到weblogic的兩個問題

          1. 用XmlHttp獲取xml,responseXml為空。
            
             解決方法:
             在web.xml中加入
             <mime-mapping>
                <extension>xml</extension>
                <mime-type>text/xml</mime-type>
             </mime-mapping>
             <mime-mapping>
                <extension>xsl</extension>
                <mime-type>text/xml</mime-type>
             </mime-mapping>

          2. 用SmartUpload下載文件時出錯   
             出錯信息:
             java.io.IOException: 文件名、目錄名或卷標語法不正確。
                  at java.io.WinNTFileSystem.canonicalize0(Native Method)
                  at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:395)
                  at java.io.File.getCanonicalPath(File.java:531)
                  at weblogic.servlet.internal.WebAppServletContext.getRealPath       

                  (WebAppServletContext.java:666)
                  at com.jspsmart.upload.SmartUpload.isVirtual(SmartUpload.java:1180)
                  Truncated. see log file for complete stacktrace
                  解決方法:自己寫了一個Servlet來下載文件,代碼如下:
            

           1public class DownLoad extends HttpServlet
           2{
           3    private static final long serialVersionUID = -84138329260803824L;
           4    public void init() throws ServletException
           5    {
           6    }

           7
           8    public void doGet(HttpServletRequest request, HttpServletResponse response) 
           9        throws ServletException, IOException
          10    {
          11        OutputStream os = null
          12        FileInputStream fis = null;
          13        try
          14        {            
          15            String fileName = request.getParameter("filename");  //要下載的文件,包括路徑
          16            String downFileName = fileName.substring(fileName.lastIndexOf("\\"+ 1); //去掉路徑
          17            
          18            os = response.getOutputStream();
          19            File f = new File(fileName);
          20            
          21            response.setHeader("Content-type:""application/octet-stream");
          22            response.setHeader("Accept-Ranges:""bytes");
          23            response.setHeader("Accept-Length:", Long.toString(f.length()));
          24            response.setHeader("Content-Disposition""attachment; filename=" + downFileName);
          25                
          26            fis = new FileInputStream(f);
          27            byte[] b = new byte[1024];    
          28            int i = 0;    
          29            while((i = fis.read(b)) > 0
          30              os.write(b, 0 ,i);
          31        }

          32        catch (Exception e)
          33        {
          34            e.printStackTrace();
          35        }

          36        finally
          37        {
          38            fis.close();
          39            os.flush();
          40            os.close();
          41        }

          42    }

          43
          44    public void doPost(HttpServletRequest request, HttpServletResponse response) 
          45       throws ServletException, IOException
          46    {
          47         doGet(request,response);
          48    }

          49}


           

          posted on 2007-09-17 22:00 afunms 閱讀(2984) 評論(3)  編輯  收藏

          Feedback

          # re: 解決從tomcat移植到weblogic的兩個問題 2008-03-05 10:09 oldgrass

          寫得非常不錯,謝謝呀  回復  更多評論   

          # re: 解決從tomcat移植到weblogic的兩個問題 2009-07-07 12:03 猜猜

          太感謝了!

          用了你的方法搞定了~~~、

          能分析下原因就更好了!  回復  更多評論   

          # re: 解決從tomcat移植到weblogic的兩個問題 2010-10-22 21:54 dahuzi

          ( ⊙o⊙ )哇!
            回復  更多評論   



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


          網站導航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 兰西县| 大兴区| 宁城县| 永昌县| 神池县| 横山县| 博兴县| 江口县| 滨州市| 益阳市| 剑阁县| 灵台县| 深州市| 郎溪县| 光山县| 甘德县| 永济市| 衡南县| 乳山市| 博罗县| 东明县| 彰武县| 临城县| 时尚| 报价| 柳林县| 阆中市| 邵东县| 满城县| 内乡县| 云南省| 南开区| 安溪县| 徐闻县| 武邑县| 瑞昌市| 资源县| 仪陇县| 兴隆县| 舒城县| 桂东县|