JSF 2.0:部署到另一台服务器后选择了错误的语言
我使用 JSF 2.0 制作了一个 Web 应用程序。它支持德语(默认)和英语,这是由在 http 标头中发送的语言选择的。
在我的本地服务器(Tomcat 6.0)上,自动语言选择是正确的,如果我将“德语”设置为最高优先级,则应用程序就是德语。英语也一样。
但现在我将它部署到我的网络服务器(Apache Web 服务器后面的 Tomcat 6.0,使用 ModJk),现在它只有英文版本。但 http 标头仍然相同:
Accept-Language: de-de,en-us;q=0.8,de;q=0.5,en;q=0.3
(Fetched from Firebug)
我的 faces-config.xml 中的语言包条目如下所示:
<application>
<locale-config>
<default-locale>de</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<resource-bundle>
<base-name>de.citkomm.tbm.locale.Lang</base-name>
<var>lang</var>
</resource-bundle>
</application>
de.citkomm.tbm.locale 中的文件“Lang.properties”和“Lang_en.properties”已正确部署。
这是 Apache + ModJk + Tomcat 6.0 的问题还是配置错误?有谁知道为什么 Tomcat 选择了错误的语言?
提前致谢!
I made a web-application with JSF 2.0. It supports german (default) and english, which is selected by the languages, sent in the http-header.
On my local server (Tomcat 6.0) the automatic language-selection was correct, if I had "german" on the highest priority, the application was german. The same for english.
But now I deployed it to my webserver (Tomcat 6.0 behind an Apache Webserver, using ModJk) and now it is only in english. But the http header is still the same:
Accept-Language: de-de,en-us;q=0.8,de;q=0.5,en;q=0.3
(Fetched from Firebug)
The entry for the language-packs in my faces-config.xml looks like this:
<application>
<locale-config>
<default-locale>de</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<resource-bundle>
<base-name>de.citkomm.tbm.locale.Lang</base-name>
<var>lang</var>
</resource-bundle>
</application>
Files "Lang.properties" and "Lang_en.properties" in de.citkomm.tbm.locale are correctly deployed.
Is this a problem with Apache + ModJk + Tomcat 6.0 or is something misconfigured? Does anyone have an idea why the wrong language is selected by Tomcat?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很奇怪......我认为 mod_jk 不应该影响这一点,因为您验证 HTTP 标头仍然包含正确的
Accept-Language
。为了进行健全性检查,如果您位于同一个内部网络上,那么您可以尝试直接访问 Tomcat Web 应用程序并完全跳过 Apache Web 服务器,但我怀疑这就是问题所在。如果您在 Tomcat 服务器环境上部署了任何公共库,那么可能正在使用不同版本的 JSF 实现,可能是存在国际化错误的早期版本。
我已经在 JBoss 和 Glassfish 等应用程序服务器上看到过这种情况,这些服务器默认情况下预先打包了自己的 JSF 实现。同样,JBoss/Glassfish 类加载器优先考虑捆绑的 JSF 实现库,而不是
WEB-INF/lib
中出现的任何 JSF 实现。然而,Tomcat 6 默认情况下不会这样做,但我仍然怀疑存在某种类加载问题。仔细检查 Web 服务器上的公共库和已部署的库,并验证那里是否存在正确的 JSF 实现。
That's strange... I would think that mod_jk should not affect this as you verify that the HTTP header still contains the correct
Accept-Language
. For a sanity-check if you are on the same internal network then you can try accessing the Tomcat web app directly and skip the Apache Web Server altogether, however I doubt this is the problem.If you have any common libraries deployed on your Tomcat server environment then it is possible that a different version of your JSF implementation is being used, possibly an earlier version that has an internationalization bug.
I have seen this occur on application servers like JBoss and Glassfish that by default come prepackaged with their own JSF implementation. Likewise the JBoss/Glassfish classloaders gave preference to the bundled JSF implementation libraries versus any JSF implementations that appear in
WEB-INF/lib
.Tomcat 6 however does not do this by default but I still suspect a classloading issue of some kind. Double check your common libraries and deployed libraries on the web server and verify that the correct JSF implementations exist there.
好吧,我不知道为什么 tomcat 使用我的 Ubuntu 服务器的环境变量,但它确实如此。
将 LANG 从“en_US.UTF-8”更改为“de_DE.UTF-8”,现在一切正常。 :S
无论如何,谢谢!
Well, I don't know why tomcat uses the evironment-variable of my Ubuntu Server, but it does.
Changed LANG from "en_US.UTF-8" to "de_DE.UTF-8" and now everything's fine. :S
Thanks anyway!