日期:2014-05-18  浏览次数:20713 次

使用cos下载的问题
cos下载的时候出现一个问题,好只支持rar、xls等格式,txt、mht等格式都不支持。

下面贴出我的代码:
jsp页面我用的是超链接如<a>downFileServlet?filepath=filepath&filename=filename</a>
后台代码
String filepath=request.getParameter("filepath");//获得文件路径
         String filename=request.getParameter("filename");//获得文件名

         String guessCharset="UTF-8";
         try {
           String isofilename = new String(filename.getBytes("ISO8859-1"),
            guessCharset);
           String isofilepath = new String(filepath.getBytes("ISO8859-1"),
            guessCharset);
           response.setContentType("application/octet-stream");
           response.setHeader("Content-Disposition",
                              "attachment; filename=" + isofilename);
           ServletOutputStream out = null;
           out = response.getOutputStream();
           ServletUtils.returnFile(isofilepath+File.separator+isofilename,out);//下载文件
         }
         catch (UnsupportedEncodingException ex) {//iso8559_1编码异常
          ex.printStackTrace();
         }catch(IOException e){//getOutputStream()异常。
           e.printStackTrace();
         }

------解决方案--------------------
参考一下http://blog.csdn.net/jadyer/article/details/6144901
------解决方案--------------------
cos是什么,没玩过,余弦莫