• springboot允许跨域


    package com.fwz.homework.cfg;
    
    import org.springframework.boot.SpringBootConfiguration;
    import org.springframework.web.servlet.config.annotation.CorsRegistry;
    import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
    
    @SpringBootConfiguration
    public class MyWebConfigurer implements WebMvcConfigurer {
    
        @Override
        public void addCorsMappings(CorsRegistry corsRegistry){
            /**
             * 所有请求都允许跨域,使用这种配置就不需要
             * 在interceptor中配置header了
             */
            corsRegistry.addMapping("/**")
                    .allowCredentials(true)
                    .allowedOrigins("http://localhost:8080")
                    .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
                    .allowedHeaders("*")
                    .maxAge(3600);
        }
    
    }
  • 相关阅读:
    Codeforces 1182E Product Oriented Recurrence 矩阵快速幂
    Codeforces 1182D Complete Mirror hash
    HDU
    HDU
    HDU
    HDU
    HDU
    HDU
    web框架之Vue渐进式框架-安装及入门
    web框架之Jqeury基本使用
  • 原文地址:https://www.cnblogs.com/fengwenzhee/p/15390361.html
Copyright © 2020-2023  润新知