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

posted on 2019-11-01 22:35  肖建锋  阅读(1666)  评论(0编辑  收藏  举报