diff --git a/src/main/java/com/petstore/controller/FileController.java b/src/main/java/com/petstore/controller/FileController.java index 041e260..d9195f8 100644 --- a/src/main/java/com/petstore/controller/FileController.java +++ b/src/main/java/com/petstore/controller/FileController.java @@ -96,7 +96,8 @@ public class FileController { .body(new FileSystemResource(file)); } - @PostMapping("/image") + /** produces 显式 UTF-8,避免网关/客户端按 ISO-8859-1 解码导致 message 中文乱码 */ + @PostMapping(value = "/image", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8") public Map uploadImage(@RequestParam("file") MultipartFile file) { Map result = new HashMap<>(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 53f9005..d12afff 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -28,6 +28,10 @@ server: port: 8080 servlet: context-path: + encoding: + charset: UTF-8 + enabled: true + force: true # 与 multipart 一致,避免嵌入式 Tomcat 仍限制表单体积导致大视频 413 tomcat: max-http-form-post-size: 200MB