我正在使用 vaadin 框架,在我的应用程序中我有:
@Override
public void onRequestStart(HttpServletRequest request,
HttpServletResponse response) {
currentIP = request.getRemoteAddr();
setLocale(request.getLocale());
handle.set(this);
this.request = request;
this.response = response;
}
但是,request.getLocale() 返回 en_US
,这是我的操作系统语言环境。然而,在用于切换语言环境的 Firefox 插件 ( https://addons.mozilla.org/cs/firefox/addon/quick-locale-switcher/?src=userprofile ) 中,我将其设置为 cs_CZ
,但是,getLocale() 仍将返回 en_US
。
最佳答案
尝试获取 session 语言环境:
UI.getCurrent().getSession().getLocale();
这对我有用。
关于java - HttpServletRequest getLocale 返回操作系统语言环境而不是浏览器语言环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19438769/