SpringBoot下载文件

来源:互联网 发布:网络教育课程是啥子 编辑:程序博客网 时间:2024/06/03 19:24
            String templateFile = "template.xls";            Resource resource = new ClassPathResource(templateFile);            response.setContentType("application/force-download");            response.addHeader("Content-Disposition",                    "attachment;fileName=" + templateFile);            IOUtils.copy(resource.getInputStream(),response.getOutputStream());            response.flushBuffer();