Java spring i18n的行为在Windows和Linux之间是不同的
我使用弹簧靴i18n 在windows中,如果所选区域设置没有句子A,它将使用messages.properties中的句子 在CentOS中,如果选择的语言环境没有句子A,它将首先使用messages_en_US.properties中的句子,如果messages_en也没有句子,它将使用messages.properties中的句子 为什么不同Java spring i18n的行为在Windows和Linux之间是不同的,java,linux,spring,internationalization,Java,Linux,Spring,Internationalization,我使用弹簧靴i18n 在windows中,如果所选区域设置没有句子A,它将使用messages.properties中的句子 在CentOS中,如果选择的语言环境没有句子A,它将首先使用messages_en_US.properties中的句子,如果messages_en也没有句子,它将使用messages.properties中的句子 为什么不同 @Bean public LocaleResolver localeResolver() { CookieLocaleResolver cl
@Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver clr = new CookieLocaleResolver();//also can use SessionLocaleResolver
clr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
return clr;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("locale");
return lci;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
我不能确切地解释这种行为,但它可能是由。Javadoc说: 如果给定的区域设置不是默认的,则默认实现返回默认的区域设置 因此,我建议检查Java默认语言环境是否有影响