我创建了一个简单的Spring应用程序,它向stdout输出一条消息。这是主要的课程:
@SpringBootApplication
public class I18nTestApplication {
public static void main(String[] args) {
final ApplicationContext ctx = SpringApplication.run(I18nTestApplication.class, args);
final Locale locale = Locale.US;
System.out.println(ctx.getMessage("test", null, locale));
}
}“资源”文件夹包含两个消息文件:
messages.properties:
test=This is Englishmessages_de.properties:
test=Das ist Deutsch预期的程序输出是:This is English,但它总是打印Das ist Deutsch作为输出。即使我设置了任何区域设置,程序也总是将德语消息打印为输出。这里发生什么事情?我搞错了吗?
发布于 2015-05-05 06:37:59
鉴于您的姓名和您的位置在您的个人资料页,我假设您的系统地区是德语。
用于查找适当资源束的算法主要由以下内容组成
文献资料中有更多信息。
提供一个名为messages_en.properties的文件(即使是空的:键也会在父包中查找),这将如预期的那样工作。
https://stackoverflow.com/questions/30045660
复制相似问题