public class MyLocaleResolver implements LocaleResolver {
//创建一个国际化器把从前端页面取到的值拆分组装成对应的新local对象
@Override
public Locale resolveLocale(HttpServletRequest httpServletRequest) {
String lan = httpServletRequest.getParameter("lan");
Locale locale = Locale.getDefault();
if (!StringUtils.isEmpty(lan)) {
String[] split = lan.split("_");
locale = new Locale(split[0], split[1]);
}
return locale;
}
@Override
public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
}
}