|
@@ -2,10 +2,17 @@ package com.jkcredit.sysnews.config;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
@Configuration
|
|
@Configuration
|
|
-public class WebConfiguration {
|
|
|
|
|
|
+public class WebConfiguration implements WebMvcConfigurer {
|
|
|
|
+ @Value("${photo.accessResource}")
|
|
|
|
+ private String accessResource;
|
|
|
|
+ @Value("${photo.veritablePath}")
|
|
|
|
+ private String veritablePath;
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(WebConfiguration.class);
|
|
private final Logger log = LoggerFactory.getLogger(WebConfiguration.class);
|
|
|
|
|
|
@@ -15,17 +22,32 @@ public class WebConfiguration {
|
|
this.applicationProperties = applicationProperties;
|
|
this.applicationProperties = applicationProperties;
|
|
}
|
|
}
|
|
|
|
|
|
-// @Bean
|
|
|
|
-// public CorsFilter corsFilter() {
|
|
|
|
-// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
|
-// CorsConfiguration config = applicationProperties.getCors();
|
|
|
|
-// if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) {
|
|
|
|
-// log.info("Registering CORS filter");
|
|
|
|
-// source.registerCorsConfiguration("/api/**", config);
|
|
|
|
-// source.registerCorsConfiguration("/management/**", config);
|
|
|
|
-// source.registerCorsConfiguration("/v2/api-docs", config);
|
|
|
|
-// }
|
|
|
|
-// return new CorsFilter(source);
|
|
|
|
-// }
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
+ registry.addResourceHandler(accessResource + "**").addResourceLocations(veritablePath);
|
|
|
|
+ }
|
|
|
|
+ //http://127.0.0.1:8081/app/page/newsArticles
|
|
|
|
+ //http://127.0.0.1:8081/app/photo/upload
|
|
|
|
+ //http://127.0.0.1:8081/app/images/202003091435211231234.png
|
|
|
|
+ //http://127.0.0.1:8081/app/images/202003091435211231235.png
|
|
|
|
+ //http://127.0.0.1:8081/app/images/202003091435211231236.png
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ application.properties
|
|
|
|
+ jkcredit.news.images.upload.path=/home/news/beans/photo
|
|
|
|
+ jkcredit.news.images.virthr.path=/home/news/beans/photo
|
|
|
|
+ jkcredit.news.access.url=https://127.0.0.1:8081
|
|
|
|
+ jkcredit.news.access.url=https://news.jkcredit.cn
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ File mkdir upload.path
|
|
|
|
+ IMAGE /201.png
|
|
|
|
+ ${jkcredit.news.access.url}${/app/images}/201.png
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ */
|
|
|
|
|
|
}
|
|
}
|