package com.example.demo.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 shiroConfig implements WebMvcConfigurer {
//解决跨域问题
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")//添加访问路径
//允许的域,配置为所有
.allowedOriginPatterns("*")
//请求方式,配置为所有
.allowedMethods("GET","HEAD","POST","DELETE","OPTIONS","PUT")
.allowCredentials(true)//是否允许,设置为是
.maxAge(3600) //设置最大连接数量
.allowedHeaders("*"); //设置响应头为全部
}
}
springboot跨域问题解决
最新推荐文章于 2024-01-17 15:04:44 发布