Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring i18n的行为在Windows和Linux之间是不同的_Java_Linux_Spring_Internationalization - Fatal编程技术网

Java spring i18n的行为在Windows和Linux之间是不同的

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

我使用弹簧靴i18n

在windows中,如果所选区域设置没有句子A,它将使用messages.properties中的句子

在CentOS中,如果选择的语言环境没有句子A,它将首先使用messages_en_US.properties中的句子,如果messages_en也没有句子,它将使用messages.properties中的句子

为什么不同

@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默认语言环境是否有影响