Commit 27fe7b54 authored by Quxl's avatar Quxl

fdsf

parent 8b819a24
......@@ -10,8 +10,6 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.common.StringUtil;
@Component
public class LocaleCookieInterceptor extends HandlerInterceptorAdapter {
......@@ -24,12 +22,12 @@ public class LocaleCookieInterceptor extends HandlerInterceptorAdapter {
for(Cookie cookie : cookies) {
if(cookie.getName().equals(language)) {
String str = cookie.getValue();
if(StringUtil.isBlank(str)) {
if(str == null || str.trim().length() == 0) {
str = "zh_CN";
}
String[] kv = str.split("_");
String[] kv = str.trim().split("_", 2);
String language = kv[0];
String country = kv.length == 2 ? kv[1] : null;
String country = kv.length > 1 ? kv[1] : null;
LocaleContextHolder.setLocale(new Locale(language, country));
return super.preHandle(req, resp, handler);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment