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;