|
|
@@ -4,14 +4,12 @@ import java.nio.charset.Charset;
|
|
|
import java.util.Arrays;
|
|
|
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.Configuration;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
|
|
|
@@ -32,9 +30,6 @@ import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|
|
@ComponentScan(basePackages = "com.uas.kanban.controller")
|
|
|
public class WebAppConfiguration extends WebMvcConfigurerAdapter {
|
|
|
|
|
|
- @Autowired
|
|
|
- private CORSFilter corsFilter;
|
|
|
-
|
|
|
@Override
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
// Spring boot默认资源路径在src/main/resources下,而非/src/main/webapp
|
|
|
@@ -77,11 +72,12 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter {
|
|
|
super.configureMessageConverters(converters);
|
|
|
}
|
|
|
|
|
|
- @Bean
|
|
|
- public FilterRegistrationBean filterRegistrationBean() {
|
|
|
- FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
|
|
- filterRegistrationBean.setFilter(corsFilter);
|
|
|
- return filterRegistrationBean;
|
|
|
+ /*
|
|
|
+ * 允许跨域访问
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void addCorsMappings(CorsRegistry registry) {
|
|
|
+ registry.addMapping("/**").allowedOrigins("*");
|
|
|
}
|
|
|
|
|
|
}
|