springboot简单解决跨域问题

package com.net.phone.recharge.config;

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

@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*").allowedMethods("*")
                .maxAge(1800)
                .allowedOrigins("*");
    }
}


版权声明:本文为liaozhaorong原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。