From da64a495ac16770a0c8697d05523d1e7cd3e8633 Mon Sep 17 00:00:00 2001 From: MaDaLei Date: Fri, 17 Apr 2026 13:21:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20WebConfig=E8=AF=BB=E5=8F=96upload.path?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=80=8C=E9=9D=9E=E7=A1=AC=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/petstore/config/WebConfig.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/petstore/config/WebConfig.java b/src/main/java/com/petstore/config/WebConfig.java index a8ee4d4..3f5fcfd 100644 --- a/src/main/java/com/petstore/config/WebConfig.java +++ b/src/main/java/com/petstore/config/WebConfig.java @@ -15,13 +15,9 @@ public class WebConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - // 硬编码绝对路径,确保能找到文件 - String uploadDir = "/Users/wac/Desktop/www/_src/petstore/backend/uploads/"; + String uploadDir = uploadPath.endsWith("/") ? uploadPath : uploadPath + "/"; System.out.println(">>> WebConfig uploadDir: " + uploadDir); - System.out.println(">>> /2026 exists: " + new File(uploadDir + "2026/04/01/").exists()); registry.addResourceHandler("/uploads/**") .addResourceLocations("file:" + uploadDir); - registry.addResourceHandler("/2026/**") - .addResourceLocations("file:" + uploadDir); } }