当前位置:网站首页>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 "";
}
}边栏推荐
- [microservice] Nacos cluster building and loading file configuration
- 如何展开Collapse 的所有折叠面板
- How to implement lazy loading in El select (with search function)
- SQL injection - injection based on MSSQL (SQL Server)
- Canoe panel learning video
- fastjson
- JSON Web Token----JWT和传统session登录认证对比
- Gridview出现滚动条,组件冲突,如何解决
- [Excel] 数据透视图
- 1480. Dynamic sum of one-dimensional array
猜你喜欢

webrtc 快速搭建 视频通话 视频会议

My NVIDIA developer journey - optimizing graphics card performance

4G wireless all network solar hydrological equipment power monitoring system bms110

Online shrimp music will be closed in January next year. Netizens call No

Halcon image calibration enables subsequent image processing to become the same as the template image

How to realize multi account login of video platform members

一键过滤选择百度网盘文件

How to avoid JVM memory leakage?

Learning multi-level structural information for small organ segmentation

BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述
随机推荐
QT QTableWidget 表格列置顶需求的思路和代码
Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
Configure cross compilation tool chain and environment variables
注释与注解
Thinkphp6.0 middleware with limited access frequency think throttle
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
Kubernets first meeting
lightroom 导入图片灰色/黑色矩形 多显示器
Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
MySQL information_ Schema database
Review | categories and mechanisms of action of covid-19 neutralizing antibodies and small molecule drugs
Upper computer software development - log information is stored in the database based on log4net
Experience weekly report no. 102 (July 4, 2022)
1480. Dynamic sum of one-dimensional array
Take you to quickly learn how to use qsort and simulate qsort
Steady! Huawei micro certification Huawei cloud computing service practice is stable!
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
gslb(global server load balance)技术的一点理解
2022.7.2-----leetcode.871
JS扁平化数形结构的数组