@RequestMapping(value = "/rardown")
public void rardown( HttpServletRequest request, String filename,
HttpServletResponse response)
throws Exception {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
/*
* String ctxPath = request.getSession().getServletContext()
* .getRealPath("/") + FileOperateUtil.UPLOADDIR; String downLoadPath =
* ctxPath + storeName;
*/
String filename1 = request.getParameter("filename");
String docId = request.getParameter("docId");
System.out.println(filename1);
// 获取目标文件的绝对路径
String downLoadPath = request.getSession().getServletContext()
.getRealPath("tsresource/" + filename1);
long fileLength = new File(downLoadPath).length();
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Content-disposition", "attachment; filename="
+ new String(filename1.getBytes("utf-8"), "ISO8859-1"));
response.setHeader("Content-Length", String.valueOf(fileLength));
bis = new BufferedInputStream(new FileInputStream(downLoadPath));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
bis.close();
bos.close();
}
public void rardown( HttpServletRequest request, String filename,
HttpServletResponse response)
throws Exception {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
/*
* String ctxPath = request.getSession().getServletContext()
* .getRealPath("/") + FileOperateUtil.UPLOADDIR; String downLoadPath =
* ctxPath + storeName;
*/
String filename1 = request.getParameter("filename");
String docId = request.getParameter("docId");
System.out.println(filename1);
// 获取目标文件的绝对路径
String downLoadPath = request.getSession().getServletContext()
.getRealPath("tsresource/" + filename1);
long fileLength = new File(downLoadPath).length();
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Content-disposition", "attachment; filename="
+ new String(filename1.getBytes("utf-8"), "ISO8859-1"));
response.setHeader("Content-Length", String.valueOf(fileLength));
bis = new BufferedInputStream(new FileInputStream(downLoadPath));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
bis.close();
bos.close();
}