@GetMapping("/download") ResponseEntity<InputStreamResource> downladFile() throws IOException { FileSystemResource file =new FileSystemResource("H:/个人简历/s.png"); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setCacheControl("no-cache,no-store,must-revalidate"); httpHeaders.setContentType(MediaType.IMAGE_JPEG); httpHeaders.setContentLength(file.contentLength()); httpHeaders.setContentDispositionFormData("attachment", URLEncoder.encode("妹妹.jpg","utf-8")); return ResponseEntity.ok() .headers(httpHeaders) .body(new InputStreamResource(file.getInputStream())); }