@GetMapping("/files/{filename:.+}")
    @ResponseBody
    public ResponseEntity<Resource> serveFile(@PathVariable String filename) {
 
        Resource file = storageService.loadAsResource(filename);
 
        String[] strArr = filename.split("\\.");
        String fileNamePrefix = strArr[0];
        String fileNameSuffix = strArr[1];
        String finalFileName = null;
        try {
            finalFileName = URLEncoder.encode(fileNamePrefix,"UTF-8")+"."+fileNameSuffix;
        }catch (UnsupportedEncodingException e){
            log.info("文件名字转换异常");
            e.printStackTrace();
        }
 
        return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION,
                "attachment; filename=\"" + finalFileName + "\"").body(file);
    }

参考:https://yq.aliyun.com/articles/38945