/**
*java打包下载ZIP压缩文件
*/
public void downZipFile() {
try {
request.setCharacterEncoding("UTF-8");
response.setContentType("application/x-compress;charset=UTF-8");
response.setHeader("Content-disposition", "attachment; filename=" + this.getZipFilename());
String url = this.request.getParameter("url");
if(url != null && !url.trim().equals("")){
//url = new String(url.getBytes("iso-8859-1"),"UTF-8");
String[] urls = url.split(",");
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
String tomcat = request.getSession().getServletContext().getRealPath("/");
File[] files = new File[urls.length];
for (int i = 0; i < files.length; i++){
files[i] = new File(tomcat+urls[i]);
}
zipFile(files, "", zos);
zos.flush();
zos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}