fix: WebConfig读取upload.path配置而非硬编码路径
This commit is contained in:
parent
f308892ba4
commit
da64a495ac
@ -15,13 +15,9 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
// 硬编码绝对路径,确保能找到文件
|
String uploadDir = uploadPath.endsWith("/") ? uploadPath : uploadPath + "/";
|
||||||
String uploadDir = "/Users/wac/Desktop/www/_src/petstore/backend/uploads/";
|
|
||||||
System.out.println(">>> WebConfig uploadDir: " + uploadDir);
|
System.out.println(">>> WebConfig uploadDir: " + uploadDir);
|
||||||
System.out.println(">>> /2026 exists: " + new File(uploadDir + "2026/04/01/").exists());
|
|
||||||
registry.addResourceHandler("/uploads/**")
|
registry.addResourceHandler("/uploads/**")
|
||||||
.addResourceLocations("file:" + uploadDir);
|
.addResourceLocations("file:" + uploadDir);
|
||||||
registry.addResourceHandler("/2026/**")
|
|
||||||
.addResourceLocations("file:" + uploadDir);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user