SpringBoot + Thymeleaf -> Question 1

H5 page

  <img th:src="files+'/'+${avatar}" ></img>
 <span th:text="${session.user.userName}+',您好!'">张三,您好</span> 

Server:

class above

@RequestMapping("/files")

method above

@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 拼接问题

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324830880&siteId=291194637