springboot2.1.3 配置前后端跨域问题
作者:互联网
很简单,创建一个配置类即可,如下:
package com.app.gateway.common.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 WebMvcConfig implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedHeaders("*") .allowedMethods("*") .maxAge(30 * 1000); } }
标签:web,springboot2.1,前后,springframework,org,import,config,annotation,跨域 来源: https://www.cnblogs.com/jimmyshan-study/p/11846239.html