Commit 61a10da9 by zhangshaowu

跨域

1 parent 39c35eba
package com.pipihelper.project.configurer; package com.pipihelper.project.configurer;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.pipihelper.project.core.Result;
import com.pipihelper.project.core.ResultCode; import com.pipihelper.project.core.ResultCode;
import com.pipihelper.project.core.ServiceException; import com.pipihelper.project.core.ServiceException;
import com.pipihelper.project.core.Result;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -36,6 +23,15 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry; ...@@ -36,6 +23,15 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* Spring MVC 配置 * Spring MVC 配置
*/ */
...@@ -101,7 +97,7 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter { ...@@ -101,7 +97,7 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") registry.addMapping("/**")
.allowedOrigins("*") .allowedOriginPatterns("*")
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE") .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
.allowCredentials(true) .allowCredentials(true)
.allowedHeaders("*") .allowedHeaders("*")
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!