@RequestMapping(value = "/downDir", method = {RequestMethod.POST, RequestMethod.GET})
public ResponseEntity<byte[]> downDir(@RequestParam("dirPath") String dirPath, HttpServletRequest request) throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// 指定返回的zip文件名,这里就直接用时间戳了,可以自己选择
headers.add("Content-Disposition", "attachment; filename=" + System.currentTimeMillis() + ".zip");
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
headers.add("Last-Modified", new Date().toString());
headers.add("ETag", String.valueOf(System.currentTimeMillis()));
ByteArrayOutputStream zos = downloadDirectory(dirPath);
byte[] out = zos.toByteArray();
zos.close();
ResponseEntity<byte[]> response = new ResponseEntity<>(out, headers, HttpStatus.OK);
return response;
}
//压缩目录
publi