Commit 8b819a24 authored by Quxl's avatar Quxl

xx

parent 92bc2456
......@@ -20,18 +20,22 @@ public class LocaleCookieInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
Cookie[] cookies = req.getCookies();
for(Cookie cookie : cookies) {
if(cookie.getName().equals(language)) {
String str = cookie.getValue();
if(StringUtil.isBlank(str)) {
str = "zh_CN";
if(cookies != null && cookies.length > 0) {
for(Cookie cookie : cookies) {
if(cookie.getName().equals(language)) {
String str = cookie.getValue();
if(StringUtil.isBlank(str)) {
str = "zh_CN";
}
String[] kv = str.split("_");
String language = kv[0];
String country = kv.length == 2 ? kv[1] : null;
LocaleContextHolder.setLocale(new Locale(language, country));
return super.preHandle(req, resp, handler);
}
String[] kv = str.split("_");
String language = kv[0];
String country = kv.length == 2 ? kv[1] : null;
LocaleContextHolder.setLocale(new Locale(language, country));
}
}
LocaleContextHolder.setLocale(Locale.CHINA);
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