Resource resource = new DefaultResourceLoader().getResource("classpath:download/WORKER_OVERTIME_RECORD.xlsx"); response.setContentType("application/x-msdownload;"); response.setHeader("Content-disposition", "attachment; filename=WORKER_OVERTIME_RECORD.xlsx"); // response.setHeader("Content-Length", String.valueOf(resource.get)); FileCopyUtils.copy(resource.getInputStream(),response.getOutputStream());
只能用inputstream, 不能是file