# 跨域配置
# 代码
package com.xxx.config
@Configuration
public class corsFilter implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") // 匹配所有的路径
.allowCredentials(true) // 设置允许凭证
.allowedHeaders("*") // 设置请求头
.allowedMethods("GET","POST","PUT","DELETE", "OPTIONS") // 设置允许的方式
.allowedOrigins("*");
}
}
← springboot 使用指南 数据库 →