refactor(music-houduan): 移除基本测试控制器并优化 Web MVC 配置
- 删除了 BasicTestController 类,不再提供基本测试接口 - 优化了 WebMvcConfig 配置类: - 移除了不必要的属性注入 - 简化了资源处理器的配置,直接使用固定的 "/upload/**" 路
This commit is contained in:
@@ -5,24 +5,19 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Web MVC 配置
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Value("${file.upload-path}")
|
||||
private String uploadPath;
|
||||
|
||||
@Value("${file.access-path}")
|
||||
private String accessPath;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// 配置上传文件资源映射
|
||||
registry.addResourceHandler(accessPath + "**")
|
||||
.addResourceLocations("file:" + uploadPath);
|
||||
|
||||
// 注意:前后端分离项目,不需要配置静态资源映射
|
||||
registry.addResourceHandler("/upload/**") // 处理这个路径的请求
|
||||
.addResourceLocations("file:" + uploadPath + "/"); // 文件路径,映射到本地文件系统
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user