【发布时间】:2016-01-12 02:01:36
【问题描述】:
我正在尝试在我的项目中实现国际化,但是我无法解析我的 BaseName,到目前为止,这是我的 AppConfiguration 类方法:
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();`
messageSource.setBasename("messages/");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
@Bean
public LocaleResolver localeResolver() {
CookieLocaleResolver resolver = new CookieLocaleResolver();
resolver.setDefaultLocale(new Locale("en_US"));
resolver.setCookieName("myLocaleCookie");
resolver.setCookieMaxAge(4800);
return resolver;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
interceptor.setParamName("mylocale");
registry.addInterceptor(interceptor);
}
这是我的项目结构: Project Structure
任何想法我做错了什么?我还尝试将我的 baseName 更改为 classpath:messages 但没有。谢谢。
【问题讨论】:
标签: java spring spring-mvc internationalization