AJAX 跨域问题
作者:互联网
在springboot的启动类的同级下建立这个config包,然后把Cors配置类放进去
@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("*");
}
}
标签:springboot,maxAge,问题,AJAX,registry,addMapping,Override,public,跨域 来源: https://blog.csdn.net/please93/article/details/121412911