利用java Cos下载
String filepath=getRequest().getRealPath("excelpath");//文件绝对路径
String filename=getRequest().getParameter("excel");//获得单个文件名
String guessCharset="gbk";
String path=filepath+"/"+filename;
try { //使用iso8559_1编码方式
String isofilename = new String(filename.getBytes(guessCharset),
"ISO-8859-1");
getResponse().setContentType("application/octet-stream");
getResponse().setHeader("Content-Disposition",
"attachment; filename=" + filename);
ServletOutputStream out = null;
out = getResponse().getOutputStream();
ServletUtils.returnFile(path,out);//下载文件
}
catch(UnsupportedEncodingException ex) {//iso8559_1编码异常
// ex.printStackTrace();
}catch(IOException e){//getOutputStream()异常。
// e.printStackTrace();
}