|
@@ -0,0 +1,23 @@
|
|
|
+package boot.common.config;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+
|
|
|
+@Configuration
|
|
|
+public class WebConfig implements WebMvcConfigurer {
|
|
|
+ @Value("${file.avatar}")
|
|
|
+ String avatar;
|
|
|
+ @Value("${file.path}")
|
|
|
+ String path;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
+ String avatarUtl = "file:" + avatar.replace("\\", "/");
|
|
|
+ String pathUtl = "file:" + path.replace("\\", "/");
|
|
|
+ registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
|
|
|
+ registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
|
|
|
+ registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
|
|
+ }
|
|
|
+}
|