Commit 96e9e0f4 authored by Quxl's avatar Quxl

xx

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