From 51e54773fe8806e413897219f7677fa768c2c739 Mon Sep 17 00:00:00 2001 From: QianRj <923207736@qq.com> Date: Fri, 22 Nov 2024 15:55:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20I18nLocaleResolver?= =?UTF-8?q?=E7=9A=84ArrayIndexOutOfBoundsException=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/common/web/core/I18nLocaleResolver.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/core/I18nLocaleResolver.java b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/core/I18nLocaleResolver.java index 98ddd06b5b..8af0f67529 100644 --- a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/core/I18nLocaleResolver.java +++ b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/core/I18nLocaleResolver.java @@ -1,9 +1,9 @@ package org.dromara.common.web.core; -import org.springframework.web.servlet.LocaleResolver; - import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.servlet.LocaleResolver; + import java.util.Locale; /** @@ -19,7 +19,11 @@ public class I18nLocaleResolver implements LocaleResolver { Locale locale = Locale.getDefault(); if (language != null && language.length() > 0) { String[] split = language.split("_"); - locale = new Locale(split[0], split[1]); + try { + locale = new Locale(split[0], split[1]); + } catch (ArrayIndexOutOfBoundsException e) { + return locale; + } } return locale; } -- Gitee