public void download(List<Map<String,Object>>list, ResponseWrapper response){
try {
String downloadFilename = "image.zip";//文件的名称
response.setContentType("application/x-download");// 指明response的返回对象是文件流
response.addHeader("Content-Disposition", "attachment;filename=" + new String(downloadFilename.getBytes("gb2312"), "ISO8859-1"));// 设置在下载框默认显示的文件名
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
for (Map<String, Object> map : list) {
String path=(String)map.get("path");//图片地址
String name=(String)map.get("name");//图片名称
URL url = new URL(path);
zos.putNextEntry(new ZipEntry(name+".jpg"));
InputStream fis = url.openConnection().getInputStream();
byte[] buffer = new byte[1024];
int r = 0;
while ((r = fis.read(buffer)) != -1) {
zos.write(buffer, 0, r);
}
fis.close();
}
zos.flush();
zos.close();
} catch (Exception e) {
// TODO Auto-generated catch block
logger.info(e);
}
}