跨域访问

package com.ctd.cloud.knowledge.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**

  • Created by user on 2019/8/22.

  • 添加支持CORS跨域访问

  • /
    @Configuration
    public class CrossDomainConfiguration implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {

      registry
              .addMapping("/**")  //配置可以被跨域的路径,可以任意配置,可以具体到直接请求路径
              .allowedMethods("*")           //允许所有的请求方法访问该跨域资源服务器,如:POST、GET、PUT、DELETE等
              .allowedOrigins("*")           //允许所有的请求域名访问我们的跨域资源,可以固定单条或者多条内容
              .allowedHeaders("*");          //允许所有的请求header访问,可以自定义设置任意请求头信息

    }
    }

全部评论

相关推荐

06-12 17:46
门头沟学院 Java
运营你豪哥:来说重点: ​1.项目前置,时间倒序。​​ 2.​项目描述强化结果与量化效果(STAR原则里的R)。​​ ​3.个人技能精炼,明确掌握程度,突出核心。​​ ​4.增加强有力开头的个人总结部分。​​ 5.​优化教育背景(成绩排名)、合并奖项与活动。​​
听劝,我这个简历该怎么改...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务