当前位置:网站首页>跨域问题解决
跨域问题解决
2022-08-02 03:21:00 【Tom没Cat】
解决方案1
SpringBoot 中添加跨域配置类 CorsConfig
package com.example.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/** * 解决跨域问题 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
}
边栏推荐
猜你喜欢

PCL—点云数据分割

@Autowired与@Resource区别

脚手架安装

Daily practice------There are n integers, so that the previous numbers are moved back m positions in order, and the last m numbers become the first m numbers

ModuleNotFoundError: No module named ‘openpyxl‘

Chapter 10 聚类

MySQL两阶段提交串讲

Mysql8.0安装教程

LeetCode:第304场周赛【总结】

DAY-1 | 求两个正整数的最大公约数与最小公倍数之和——辗转相除法
随机推荐
5. Hezhou Air32F103_LCD_key
rem adaptation
关于#sql#的问题:该怎么写sql语句,
MySQL分区表详解
AntV X6制作画板工具(图形,线段,图片上传)
分布式领域最重要的一篇论文,到底讲了什么?
@DateTimeFormat注解
MySQL分库分表
黑马案例--实现 clock 时钟的web服务器
(Reposted) The relationship between hashcode and equals
MySQL分组后取最大一条数据【最优解】
STL入门基础 map和set容器
MySQL删除表数据 MySQL清空表命令 3种方法
Daily practice------There are n integers, so that the previous numbers are moved back m positions in order, and the last m numbers become the first m numbers
py0_二十一天计划书
HCIP Day 11_MPLS Experiment
Scaffolding installation
MySQL分组后排序
【遥控器开发基础教程3】疯壳·开源编队无人机-ADC(摇杆控制)
Double Strings (别总忘记substr)