From de4de57a6856ff07fc02c154e0d35a67f3ff9550 Mon Sep 17 00:00:00 2001 From: caojianbin <1910336823> Date: Tue, 26 Jul 2022 10:07:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E5=85=B3=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E6=94=B9=E9=80=A002?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/gateway/constant/MessagesConstant.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/constant/MessagesConstant.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/constant/MessagesConstant.java index 16f93ce..2f59a0c 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/constant/MessagesConstant.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/constant/MessagesConstant.java @@ -49,7 +49,7 @@ public class MessagesConstant { */ public static String getMessages(ServerWebExchange exchange, String zh_msg, String en_msg) { //给一个默认值 - String msg=zh_msg; + String msg=en_msg; ServerHttpRequest request = exchange.getRequest(); if (request.getHeaders().containsKey(MessagesConstant.HEADER_KEY)) { String zh = exchange.getRequest().getHeaders().getFirst(MessagesConstant.Language_ZH); @@ -59,7 +59,8 @@ public class MessagesConstant { msg = en_msg; } }else { - String s = request.getHeaders().get("accept-language").get(0).split(",")[1]; + String s = request.getHeaders().get("accept-language").get(0).split(",")[0].split("-")[0]; + log.info("获取头部的accept-language值:",request.getHeaders().get("accept-language")); log.info("获取头部的语言:{}",s); if (MessagesConstant.Language_ZH.equals(s)) { msg = zh_msg;