|
@@ -1,10 +1,16 @@
|
|
package cn.com.ctop.okr.config;
|
|
package cn.com.ctop.okr.config;
|
|
|
|
|
|
|
|
+import cn.com.ctop.okr.interceptors.BrowseLogHandelInterceptor;
|
|
|
|
+import cn.com.ctop.okr.utils.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
import org.springframework.web.filter.CorsFilter;
|
|
import org.springframework.web.filter.CorsFilter;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -15,6 +21,22 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
*/
|
|
*/
|
|
@Configuration
|
|
@Configuration
|
|
public class WebMvcConfiguration implements WebMvcConfigurer {
|
|
public class WebMvcConfiguration implements WebMvcConfigurer {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ BrowseLogHandelInterceptor browseLogHandelInterceptor;
|
|
|
|
+
|
|
|
|
+ @Value("${jeecg.path.upload}")
|
|
|
|
+ private String upLoadPath;
|
|
|
|
+ @Value("${jeecg.path.webapp}")
|
|
|
|
+ private String webAppPath;
|
|
|
|
+ @Value("${spring.resource.static-locations}")
|
|
|
|
+ private String staticLocations;
|
|
|
|
+
|
|
|
|
+// @Override
|
|
|
|
+// public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
+// registry.addInterceptor(browseLogHandelInterceptor);
|
|
|
|
+// }
|
|
|
|
+
|
|
@Bean
|
|
@Bean
|
|
public CorsFilter corsFilter() {
|
|
public CorsFilter corsFilter() {
|
|
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
|
|
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
|
|
@@ -30,4 +52,22 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
|
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
|
|
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
|
|
return new CorsFilter(urlBasedCorsConfigurationSource);
|
|
return new CorsFilter(urlBasedCorsConfigurationSource);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 静态资源的配置 - 使得可以从磁盘中读取 Html、图片、视频、音频等
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
+ registry.addResourceHandler("/**")
|
|
|
|
+ .addResourceLocations("file:" + upLoadPath + "//", "file:" + webAppPath + "//")
|
|
|
|
+ .addResourceLocations(staticLocations.split(StringUtils.COMMA));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 访问根路径默认跳转 index.html页面 (简化部署方案: 可以把前端打包直接放到项目的 webapp,上面的配置)
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void addViewControllers(ViewControllerRegistry registry) {
|
|
|
|
+ registry.addViewController("/").setViewName("index.html");
|
|
|
|
+ }
|
|
}
|
|
}
|