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);
}
}