From 81174d8eb39515eb11d5f424ffe087cf4fdcfa11 Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Fri, 6 Jan 2023 17:32:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/main/java/cn/jlw/filter/CorsFilter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/main/java/cn/jlw/filter/CorsFilter.java b/web/src/main/java/cn/jlw/filter/CorsFilter.java index 817ce2e2..bfc69a24 100644 --- a/web/src/main/java/cn/jlw/filter/CorsFilter.java +++ b/web/src/main/java/cn/jlw/filter/CorsFilter.java @@ -13,13 +13,13 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; -import static cn.jlw.filter.CorsFilter.ALLOW_ORIGIN; +import static cn.jlw.filter.CorsFilter.ORIGIN_HEADER_PLACEHOLDER; //cors跨域处理 //TODO 方便调试,allowOrigin暂时适用*,之后改为前端地址 @WebFilter(filterName = "corsFilter", urlPatterns = "/*", - initParams = {@WebInitParam(name = "allowOrigin", value = ALLOW_ORIGIN), + initParams = {@WebInitParam(name = "allowOrigin", value = ORIGIN_HEADER_PLACEHOLDER), @WebInitParam(name = "allowMethods", value = "GET,POST,PUT,DELETE,OPTIONS"), @WebInitParam(name = "allowCredentials", value = "true"), @WebInitParam(name = "allowHeaders", value = "Content-Type,X-Token,token,isWx,_sign,_role_tag"), @@ -29,7 +29,7 @@ public class CorsFilter implements Filter { /** * 请求头中取Origin, 占位 */ - static final String ALLOW_ORIGIN = "ORIGIN_HEADER_PLACEHOLDER"; + static final String ORIGIN_HEADER_PLACEHOLDER = "ORIGIN_HEADER_PLACEHOLDER"; private final Log log = LogFactory.getLog(this.getClass()); @@ -57,7 +57,7 @@ public class CorsFilter implements Filter { if(allowOrigin.equals("*")){ response.setHeader("Access-Control-Allow-Origin", allowOrigin); } - else if(allowOrigin.equals(ALLOW_ORIGIN)) { + else if(allowOrigin.equals(ORIGIN_HEADER_PLACEHOLDER)) { response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); }else{ List allowOriginList = Arrays.asList(allowOrigin.split(","));