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
网友评论