我遇到了Ubuntu 10.04.1 LTS x86_64的一个奇怪问题,当系统区域设置为en_US时,一切似乎都能正常工作。但是,当系统区域设置为en_GB时,Spring会尝试将默认资源包查找为en_us而不是en_US。
例外:
06-Oct-2010 23:35:12 org.springframework.context.support.ResourceBundleMessageSource getResourceBundle
WARNING: ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages, locale en_us
系统区域设置:
taylor@taylor-laptop:~$ locale
LANG=en_GB.utf8
LC_CTYPE="en_GB.utf8"
LC_NUMERIC="en_GB.utf8"
LC_TIME="en_GB.utf8"
LC_COLLATE="en_GB.utf8"
LC_MONETARY="en_GB.utf8"
LC_MESSAGES="en_GB.utf8"
LC_PAPER="en_GB.utf8"
LC_NAME="en_GB.utf8"
LC_ADDRESS="en_GB.utf8"
LC_TELEPHONE="en_GB.utf8"
LC_MEASUREMENT="en_GB.utf8"
LC_IDENTIFICATION="en_GB.utf8"
LC_ALL=
taylor@taylor-laptop:~$
默认的Spring语言环境设置如下:
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="cookieName" value="USER_LOCALE" />
<property name="cookieMaxAge" value="1209600" />
<property name="defaultLocale" value="en_US" />
</bean>
答案 0 :(得分:3)
我已经在Ubuntu VM上检查了上面github链接中的代码,甚至改变了我的语言环境以匹配你的代码:
matt@ubuntu-vm:~/google-app-engine-jappstart$ locale
LANG=en_GB.utf8
LANGUAGE=en_GB:en
LC_CTYPE="en_GB.utf8"
LC_NUMERIC="en_GB.utf8"
LC_TIME="en_GB.utf8"
LC_COLLATE="en_GB.utf8"
LC_MONETARY="en_GB.utf8"
LC_MESSAGES="en_GB.utf8"
LC_PAPER="en_GB.utf8"
LC_NAME="en_GB.utf8"
LC_ADDRESS="en_GB.utf8"
LC_TELEPHONE="en_GB.utf8"
LC_MEASUREMENT="en_GB.utf8"
LC_IDENTIFICATION="en_GB.utf8"
LC_ALL=
当我运行mvn gae:run
时,我可以打开您的webapp的索引页面。我甚至已经验证过,如果我从index.jsp打印出java.util.Locale.getDefault()
的值,则值为en_GB
。
您确定没有其他设置导致此问题吗?我试图错误地重现它吗?