//导出Excel try { HSSFWorkbook wb = carService.export(list); //调用service方法~! response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=carsList.xls"); OutputStream ouputStream = response.getOutputStream(); wb.write(ouputStream); ouputStream.flush(); ouputStream.close(); } catch (Exception e) { logger.error("车辆信息导出excel错误:", e); } return null; //导出zip文件 //response.reset(); response.setCharacterEncoding("utf-8"); response.setContentType("application/octet-stream;charset=UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=\"" + zipName + "\""); InputStream is = new FileInputStream(zipFile); //是文件而不是文件名。 FileCopyUtils.copy(is, response.getOutputStream());//将文件写到输出流中 return null;