Spring Boot全局支持CORS(跨源请求)

 import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /**
* @Author:CoderZZ
* @Description:Spring Boot全局支持CORS(跨源请求)
* @Date:Created in 10:57 2018/2/8.
*/
@Configuration
public class WebCorsConfigurerAdapter extends WebMvcConfigurerAdapter
{ @Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").
allowedOrigins("*").
allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS").
allowedHeaders("Content-Type","Access-Control-Allow-Headers","Authorization","X-Requested-With").
allowCredentials(true);
}
}
上一篇:linux文件系统与存储结构


下一篇:jq插件模板