跨域问题
作者:互联网
全局跨域: 重写视图解析器addCorsMappings
/** * 解决跨域问题 */ @Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") .allowCredentials(true) .maxAge(3600) .allowedHeaders("*"); } }
单个方法/类 跨域:@CrossOrigin
标签:addCorsMappings,跨域,maxAge,视图,问题,registry,public 来源: https://www.cnblogs.com/hbhb/p/14207767.html