1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Java 后台解决与前端的跨域问题

Java 后台解决与前端的跨域问题

时间:2021-07-12 16:43:32

相关推荐

Java 后台解决与前端的跨域问题

在deploy模块的config包里,添加CorsConfig类

import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.CorsRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;@Configurationpublic class CorsConfig extends WebMvcConfigurerAdapter {@Overridepublic void addCorsMappings(CorsRegistry registry) {registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedMethods("GET", "POST", "DELETE", "PUT","OPTIONS").maxAge(3600);}}

搞定~~

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。