0
在我的Spring MVC Web的应用程序,我救下Spring MVC的类路径
|-src/main/java
+---src
| +---main
| | +---java
| | +---resources
| | | +---i18n
| message_en.properties
| message_fr.properties
bean声明message_en.properties文件:
@Bean
public ReloadableResourceBundleMessageSource validationMessageSource() {
ReloadableResourceBundleMessageSource bms = new ReloadableResourceBundleMessageSource();
bms.setBasename("classpath*:i18n/message");
bms.setDefaultEncoding("UTF-8");
return bms;
}
@Bean
public CookieLocaleResolver localeResolver() {
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
localeResolver.setDefaultLocale(Locale.ENGLISH);
localeResolver.setCookieName("my-locale-cookie");
localeResolver.setCookieMaxAge(3600);
return localeResolver;
}
@Bean
public LocaleChangeInterceptor localeInterceptor() {
LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
interceptor.setParamName("lang");
return interceptor;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeInterceptor());
}
在控制台中我仍然得到消息:
DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - No properties file found for [classpath*:i18n/message] - neither plain properties nor XML
16:13:24.432 [http-nio-8080-exec-3] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - No properties file found for [classpath*:i18n/message_fr] - neither plain properties nor XML
16:13:24.432 [http-nio-8080-exec-3] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - No properties file found for [classpath*:i18n/message_fr_FR] - neither plain properties nor XML
16:13:24.432 [http-nio-8080-exec-3] DEBUG org.springframework.context.support.ReloadableResourceBundleMessageSource - No properties file found for [classpath*:i18n/message_en] - neither plain properties nor XML
请问如何在validationMessageSource Bean中设置属性Basename。
THX现在去罚款 – alveomaster