springbootv 2.4.0跨域

package com.cmrx.dzwz.util;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.util.StringUtils;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.IOException;
import java.text.SimpleDateFormat;

/**
 * Description: new java files header..
 *
 * @author 王维
 * @version 1.0
 * @date 2023/10/17 17:07
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOriginPatterns("*")
                .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
                .allowCredentials(true).maxAge(3600);
    }
}

相关推荐

  1. 05 SpringBoot

    2024-01-27 14:18:01       27 阅读
  2. springbootv 2.4.0

    2024-01-27 14:18:01       31 阅读
  3. SpringBoot+Vue项目问题

    2024-01-27 14:18:01       17 阅读
  4. springboot项目如何配置

    2024-01-27 14:18:01       13 阅读
  5. SpringBoot对接口配置设置

    2024-01-27 14:18:01       11 阅读
  6. springboot项目设置总结

    2024-01-27 14:18:01       11 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-27 14:18:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-27 14:18:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-27 14:18:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-27 14:18:01       20 阅读

热门阅读

  1. 24校招,经纬恒润测试工程师PPT技术二面

    2024-01-27 14:18:01       34 阅读
  2. Qt程序设计-U盘检测(windows)

    2024-01-27 14:18:01       33 阅读
  3. C++特殊类设计

    2024-01-27 14:18:01       29 阅读
  4. 网站服务器出错的原因是什么?

    2024-01-27 14:18:01       34 阅读
  5. SpringMVC之REST风格

    2024-01-27 14:18:01       38 阅读
  6. 2024-01-24-redis学习笔记

    2024-01-27 14:18:01       23 阅读
  7. springmvc-dispatcherserlet

    2024-01-27 14:18:01       25 阅读
  8. XR虚拟拍摄技术:开启短剧与微剧的全新篇章

    2024-01-27 14:18:01       44 阅读
  9. 使用 Spark MLlib 使用 jieba 分词训练中文分类器

    2024-01-27 14:18:01       34 阅读
  10. SASS简介及使用方法

    2024-01-27 14:18:01       29 阅读
  11. 【办公自动化】Python中的BeautifulSoup

    2024-01-27 14:18:01       36 阅读
  12. PHP AES加解密:用代码为数据加上保护的盾牌

    2024-01-27 14:18:01       37 阅读