添加第三方jar到Spring Boot application 2020年9月11日 | it java spring maven 背景 有时候需要添加第三方的jar包到spring boot工程中,因为不能从maven repository直接下载,所以需要包含在代码库中。 一般需要在 src/main 目录下,可以建个新目录 lib, 然后把jar文件放到这个目录下,也就是 src/main/lib下. 然后在pom.xml中需要添加 group…… 阅读全文
Vue File Download From Spring Boot 2020年9月10日 | it vue spring File download 如果spring boot的写法是我在另外一个文章, 返回的response其实是一个Blob, 这一点要记住 this.axios.get(url, { responseType: 'blob', timeout: 0 }).then(response => { // response is Blob <------- const url = window.URL.createObjectURL(response) const a = document.createElement('a') a.style.display = 'none' a.href = url a.setAttribute('download','file.xlsx') document.body.appendChild(a) a.click() document.body.removeChild(a); window.URL.revokeObjectURL(url); });…… 阅读全文
Spring Boot File Download 2020年9月10日 | it spring java spring boot application 提供下载的代码,可以返回一个Resource @RestController @RequiredArgsConstructor @RequestMapping("/api") public class ReportController { @GetMapping(value = "/filedownload") public ResponseEntity<InputStreamResource> downloadFile(HttpServletRequest request) { // ....................... // ....................... // ....................... ByteArrayInputStream stream = xxxxxx;// get the stream return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=file.xlsx") .body(new InputStreamResource(stream)); } }…… 阅读全文