|
|
@@ -2,6 +2,8 @@ package cn.seecoder.courselearning.config;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
@@ -19,4 +21,10 @@ public class WebResourceConfig implements WebMvcConfigurer {
|
|
|
// 在当前配置下,如果后端在本地运行,访问上传的文件资源,只需访问路径 http://localhost:8081/file/{file_name}
|
|
|
registry.addResourceHandler("/file/**").addResourceLocations("file:"+fileUploadPath);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void configurePathMatch(PathMatchConfigurer configurer) {
|
|
|
+ // 为所有的RestController暴露的服务接口url 添加前缀/api
|
|
|
+ configurer.addPathPrefix("/api", c -> c.isAnnotationPresent(RestController.class));
|
|
|
+ }
|
|
|
}
|