当前位置:网站首页>跨域问题解决
跨域问题解决
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("*");
}
}
边栏推荐
猜你喜欢
随机推荐
两对象数组比较拿出不同值方法
Monaco Editor 的基本用法
Brute force visitors
腾讯50题
深度自编码网络的集成学习ICPS入侵检测模型
C语言力扣第47题全排列 II。搜索回溯
数据库操作作业
基于可逆网络的单一图像超分辨率
STM32——LCD—TFTLCD原理与配置介绍
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
DSPE-PEG-PDP,DSPE-PEG-OPSS,磷脂-聚乙二醇-巯基吡啶供应,MW:5000
(forwarded) HashCode summary (2)
MySQL分页查询的5种方法
【深度学习】从LeNet-5识别手写数字入门深度学习
青蛙跳台阶:我如何得知它是一道斐波那契数列题?——应用题破题“三板斧”
线性代数学习笔记3-3:逆矩阵的理解
关于#sql#的问题:该怎么写sql语句,
rem adaptation
Freeswitch操作基本配置
LeetCode:1374. 生成每种字符都是奇数个的字符串【签到题】









