赞
踩
- import org.springframework.context.annotation.Configuration;
- import org.springframework.web.servlet.config.annotation.CorsRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-
- @Configuration
- public class CrossDomain extends WebMvcConfigurerAdapter {
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- registry.addMapping("/**").allowedOrigins("*")
- .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
- .allowCredentials(false).maxAge(3600);
- }
直接添加配置类即可,使用CROS配置跨域
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。