22301138 | c1017df | 2025-06-05 16:11:39 +0800 | [diff] [blame] | 1 | package com.example.myproject.config; |
| 2 | |
| 3 | import org.springframework.context.annotation.Configuration; |
| 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| 6 | |
| 7 | @Configuration |
| 8 | public class WebConfig implements WebMvcConfigurer { |
| 9 | @Override |
| 10 | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| 11 | // 访问 /uploads/** 映射到本地 D:/Desktop/echo/echo-backend/uploads/ |
| 12 | registry.addResourceHandler("/uploads/**") |
| 13 | .addResourceLocations("file:D:/PT/echo-backend/uploads/"); |
| 14 | } |
| 15 | } |