From d824675168f02b2b369f6db05fc8aa60a68c18e3 Mon Sep 17 00:00:00 2001 From: Hacker <721806280@qq.com> Date: Thu, 20 Jan 2022 06:32:39 +0000 Subject: [PATCH] update pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java. --- .../java/com/pig4cloud/pig/common/core/util/WebUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java index 2c9986e9..1b6117c0 100755 --- a/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java +++ b/pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/util/WebUtils.java @@ -18,6 +18,7 @@ package com.pig4cloud.pig.common.core.util; import cn.hutool.core.codec.Base64; import cn.hutool.json.JSONUtil; +import com.pig4cloud.pig.common.core.constant.CommonConstants; import com.pig4cloud.pig.common.core.exception.CheckedException; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; @@ -36,7 +37,6 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import java.io.IOException; import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.Optional; @@ -143,7 +143,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils { * @param contentType contentType */ public void renderJson(HttpServletResponse response, Object result, String contentType) { - response.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding(CommonConstants.UTF8); response.setContentType(contentType); try (PrintWriter out = response.getWriter()) { out.append(JSONUtil.toJsonStr(result)); @@ -164,7 +164,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils { } @SneakyThrows - public String getClientId(HttpServletRequest request) { + public String getClientId() { if (WebUtils.getRequest().isPresent()) { String header = WebUtils.getRequest().get().getHeader(HttpHeaders.AUTHORIZATION); return splitClient(header)[0]; @@ -173,7 +173,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils { } @NotNull - private static String[] splitClient(String header) throws UnsupportedEncodingException { + private static String[] splitClient(String header) { if (header == null || !header.startsWith(BASIC_)) { throw new CheckedException("请求头中client信息为空"); }