美文网首页
springboot跨域

springboot跨域

作者: 次序 | 来源:发表于2019-01-25 10:03 被阅读0次
package com.trojan.util;

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

/**

 * @author zhangcunli
 
 * 解决跨域问题
 */
@Configuration
public class Cors implements WebMvcConfigurer {
    
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
        .allowedOrigins("*")
        .allowedMethods("GET", "POST", "PUT", "OPTIONS", "DELETE", "PATCH")
          .allowCredentials(true).maxAge(3600);
    }
    
    
}

相关文章

网友评论

      本文标题:springboot跨域

      本文链接:https://www.haomeiwen.com/subject/ydfmjqtx.html