Java struts 2中的区域设置未更改
由于struts 2的默认I18nInterceptor在系统分布式时失败,因此我实现了一个基于cookie的解决方案。我添加了一个拦截器,用于查找request_locale参数并设置cookie。它也在寻找饼干。如果请求_locale参数出现或cookie存在,我将设置新的区域设置。这个拦截器是在struts的I18N拦截器之后调用的。但是设置之后,我看不到语言的变化。下面是我的拦截器的截取方法Java struts 2中的区域设置未更改,java,struts2,locale,interceptor,setlocale,Java,Struts2,Locale,Interceptor,Setlocale,由于struts 2的默认I18nInterceptor在系统分布式时失败,因此我实现了一个基于cookie的解决方案。我添加了一个拦截器,用于查找request_locale参数并设置cookie。它也在寻找饼干。如果请求_locale参数出现或cookie存在,我将设置新的区域设置。这个拦截器是在struts的I18N拦截器之后调用的。但是设置之后,我看不到语言的变化。下面是我的拦截器的截取方法 public String intercept(ActionInvocation invocat
public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String localeStr = request.getParameter("request_locale");
if (localeStr != null) {
setLocaleInCookie(localeStr);
}
if (localeStr == null) {
localeStr = getLocaleFromCookie();
}
if (localeStr != null) {
ActionContext.getContext().setLocale(new Locale(localeStr));
}
return invocation.invoke();
}
我想知道我所做的是否正确。是否有其他解决方案或解决方法?请参阅。尝试了该代码,仍然没有任何区别。