Spring Boot全局支持CORS(跨源请求)
2020-12-13 03:49
标签:str col extend err desc origin rip dma web Spring Boot全局支持CORS(跨源请求) 标签:str col extend err desc origin rip dma web 原文地址:https://www.cnblogs.com/Java-Script/p/11089859.html 1 import org.springframework.context.annotation.Configuration;
2 import org.springframework.web.servlet.config.annotation.CorsRegistry;
3 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
4
5 /**
6 * @Author:CoderZZ
7 * @Description:Spring Boot全局支持CORS(跨源请求)
8 * @Date:Created in 10:57 2018/2/8.
9 */
10 @Configuration
11 public class WebCorsConfigurerAdapter extends WebMvcConfigurerAdapter
12 {
13
14 @Override
15 public void addCorsMappings(CorsRegistry registry) {
16 registry.addMapping("/**").
17 allowedOrigins("*").
18 allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS").
19 allowedHeaders("Content-Type","Access-Control-Allow-Headers","Authorization","X-Requested-With").
20 allowCredentials(true);
21 }
22 }
上一篇:俄罗斯方块:win32api开发