当前位置:网站首页>How to implement cross domain requests
How to implement cross domain requests
2022-07-04 06:02:00 【Daily enlightenment】
Method 1 :
@Configuration
public class CorsConfig {
private CorsConfiguration buildConfig(){
CorsConfiguration configuration = new CorsConfiguration();
// Set properties
// Addresses that allow cross domain requests ,* Express all
configuration.addAllowedOrigin("*");
// Configure cross domain request headers
configuration.addAllowedHeader("*");
// Configure cross domain request methods
configuration.addAllowedMethod("*");
// Indicates whether the same is used for cross domain requests session
configuration.setAllowCredentials(true);
return configuration;
}
@Bean
public CorsFilter corsFilter(){
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**",buildConfig());
return new CorsFilter(source);
}
}
Method 2 :
@CrossOrigin(origins = "*",allowedHeaders = "*",methods = {},allowCredentials = "true")
@RestController
@CrossOrigin(origins = "*",allowedHeaders = "*",methods = {},allowCredentials = "true")
public class TestController {
@RequestMapping("/auth/login")
public String test(){
System.out.println("test");
return "";
}
}边栏推荐
- el-select如何实现懒加载(带搜索功能)
- Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
- How to implement lazy loading in El select (with search function)
- Install pytoch geometric
- Gridview出现滚动条,组件冲突,如何解决
- QT get random color value and set label background color code
- js获取对象中嵌套的属性值
- MySQL的information_schema数据库
- One click filtering to select Baidu online disk files
- BUU-Crypto-[GUET-CTF2019]BabyRSA
猜你喜欢

Sword finger offer II 038 Daily temperature
![[Excel] 数据透视图](/img/45/be87e4428a1d8ef66ef34a63d12fd4.png)
[Excel] 数据透视图

Google Chrome browser will support the function of selecting text translation
![[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx](/img/a9/72791cbcc6c9da45e89450ab2820c1.jpg)
[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx

【无标题】

How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?

JS how to convert seconds into hours, minutes and seconds display

注释与注解

Accidentally deleted the data file of Clickhouse, can it be restored?

Detectron: train your own data set -- convert your own data format to coco format
随机推荐
Design and implementation of tcp/ip series overview
HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
每周小结(*63):关于正能量
BUU-Crypto-[GXYCTF2019]CheckIn
Experience weekly report no. 102 (July 4, 2022)
1480. Dynamic sum of one-dimensional array
注释与注解
ES6 模块化
Json Web token - jwt vs. Traditional session login Authentication
el-select如何实现懒加载(带搜索功能)
(4) Canal multi instance use
How to avoid JVM memory leakage?
Nexus 6p从8.0降级6.0+root
Lightroom import picture gray / Black rectangular multi display
Install pytoch geometric
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
How to configure static IP for Kali virtual machine
Functions in C language (detailed explanation)
px em rem的区别
Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage