Commit 96e9e0f4 authored by Quxl's avatar Quxl

xx

parent 79a3f0ec
...@@ -2,7 +2,6 @@ package com.egolm.film.config.interceptor; ...@@ -2,7 +2,6 @@ package com.egolm.film.config.interceptor;
import java.util.Locale; import java.util.Locale;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -17,23 +16,14 @@ public class LocaleCookieInterceptor extends HandlerInterceptorAdapter { ...@@ -17,23 +16,14 @@ public class LocaleCookieInterceptor extends HandlerInterceptorAdapter {
@Override @Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception { public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
Cookie[] cookies = req.getCookies(); String str = req.getParameter(language);
if(cookies != null && cookies.length > 0) { if(str == null || str.trim().length() == 0) {
for(Cookie cookie : cookies) { str = "zh_CN";
if(cookie.getName().equals(language)) { }
String str = cookie.getValue(); String[] kv = str.trim().split("_", 2);
if(str == null || str.trim().length() == 0) { String language = kv[0];
str = "zh_CN"; String country = kv.length > 1 ? kv[1] : "";
} LocaleContextHolder.setLocale(new Locale(language, country));
String[] kv = str.trim().split("_", 2);
String language = kv[0];
String country = kv.length > 1 ? kv[1] : "";
LocaleContextHolder.setLocale(new Locale(language, country));
return super.preHandle(req, resp, handler);
}
}
}
LocaleContextHolder.setLocale(Locale.CHINA);
return super.preHandle(req, resp, handler); 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