我无法读取application.properties文件,但我能够阅读messages_en_IN.properties文件。
我正在使用maven项目,我的两个属性文件都在资源文件夹
中以下是我的配置
public class WebAppConfig extends WebMvcConfigurerAdapter {
// resource bundle configuration
@Bean
public ReloadableResourceBundleMessageSource messageSource(){
ReloadableResourceBundleMessageSource messageSource=new ReloadableResourceBundleMessageSource();
String[] resources= {"classpath:messages"};
messageSource.setBasenames(resources);
return messageSource;
}
@Bean
public LocaleResolver localeResolver() {
final CookieLocaleResolver ret = new CookieLocaleResolver();
ret.setDefaultLocale(new Locale("en_IN"));
return ret;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor(){
LocaleChangeInterceptor localeChangeInterceptor=new LocaleChangeInterceptor();
localeChangeInterceptor.setParamName("language");
return localeChangeInterceptor;
}
// properties file configuration
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer propertySources = new PropertySourcesPlaceholderConfigurer();
org.springframework.core.io.Resource[] resources = new ClassPathResource[ ] { new ClassPathResource( "application.properties" ) };
propertySources.setLocations((org.springframework.core.io.Resource[]) resources);
return propertySources;
}
}
JSP:读取属性
spring:消息代码=" label.maxlength"
异常:
No message found under code 'label.maxlength' for locale 'en_in'
label.maxlength在application.properties中,但是如果我尝试从messages_en_IN.properties中读取内容,那么它工作正常。为什么它不是从application.properties读取
由于