SpringBoot+Thymeleaf->問題1
阿新 • • 發佈:2018-04-25
springboot thymeleaf H5頁面
<img th:src="files+‘/‘+${avatar}" ></img>
<span th:text="${session.user.userName}+‘,您好!‘">張三,您好</span>
服務端:
類上面
@RequestMapping("/files")
方法上面
@GetMapping("/{filename:.+}") @ResponseBody public ResponseEntity<Resource> serveFile(@PathVariable String filename) { Resource file = storageService.loadAsResource(filename); return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getFilename() + "\"").body(file); } 主要是 url 拼接問題
SpringBoot+Thymeleaf->問題1