Я решил это. Решение заключается в реализации LocaleChangeInterceptor
,
Весной этого класса preHandle является:
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException {
String newLocale = request.getParameter(this.paramName);
if (newLocale != null && this.checkHttpMethod(request.getMethod())) {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
if (localeResolver == null) {
throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
}
localeResolver.setLocale(request, response, StringUtils.parseLocaleString(newLocale));
}
return true;
}
Мой метод preHandle:
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException {
if (this.checkHttpMethod(request.getMethod())) {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
if (localeResolver == null) {
throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
}
localeResolver.setLocale(request, response, I18nUtil.getLocaleByUrl(request.getServletPath()));
}
return true;
}
Просто внедрите I18nUtil.getLocaleByUrl(request.getServletPath())
.
Большое спасибо! @M. Deinum