<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 拼接问题
原文地址:http://blog.51cto.com/360douruanliang/2107760