springboot允许跨域访问
2021-02-19 12:19
标签:cross delete try 后端开发 eth actor als factory 学习 前后端开发学习中,vue里面需要跨域访问后台数据 可在springboot后台里面添加个配置类即可: springboot允许跨域访问 标签:cross delete try 后端开发 eth actor als factory 学习 原文地址:https://www.cnblogs.com/bingyangzhang/p/12684818.htmlpackage com.springboottest.config;
import org.springframework.beans.factory.annotation.Configurable;
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 CrossConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
}
上一篇:不重装anaconda升级base中的Python版本
下一篇:算法导论练习1.1