|
@@ -4,6 +4,9 @@ import java.nio.charset.Charset;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
@@ -29,6 +32,9 @@ import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
@ComponentScan(basePackages = "com.uas.kanban.controller")
|
|
@ComponentScan(basePackages = "com.uas.kanban.controller")
|
|
|
public class WebAppConfiguration extends WebMvcConfigurerAdapter {
|
|
public class WebAppConfiguration extends WebMvcConfigurerAdapter {
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CORSFilter corsFilter;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
// Spring boot默认资源路径在src/main/resources下,而非/src/main/webapp
|
|
// Spring boot默认资源路径在src/main/resources下,而非/src/main/webapp
|
|
@@ -71,4 +77,11 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter {
|
|
|
super.configureMessageConverters(converters);
|
|
super.configureMessageConverters(converters);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Bean
|
|
|
|
|
+ public FilterRegistrationBean filterRegistrationBean() {
|
|
|
|
|
+ FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
|
|
|
|
+ filterRegistrationBean.setFilter(corsFilter);
|
|
|
|
|
+ return filterRegistrationBean;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|