[英]why is my localeresolver printing the localecode instead of the content?
When I want to display an internationalized message from the properties files the webpage displays ??headline_en??
当我要显示属性文件中的国际化消息时,网页显示“
??headline_en??
instead. 代替。 Does anyone know what is causing this?
有谁知道是什么原因造成的? This is my properties file.
这是我的属性文件。
headline = Welcome to my Site
intro = this is my english intro
And these are the required beans I use for localization: 这些是我用于本地化所需的bean:
@Bean //https://phraseapp.com/blog/posts/how-to-localize-spring-applications-like-a-pro/
public LocaleResolver localeResolver(){
SessionLocaleResolver sessionLocaleResolver = new SessionLocaleResolver();
sessionLocaleResolver.setDefaultLocale(Locale.US);
return sessionLocaleResolver;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor(){
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
localeChangeInterceptor.setParamName("lang");
return localeChangeInterceptor;
}
@Bean
public MessageSource messageSource(){
ReloadableResourceBundleMessageSource messageSource =
new ReloadableResourceBundleMessageSource();
messageSource.setBasename("language");
messageSource.setCacheSeconds(10);
return messageSource;
}
@Override
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(localeChangeInterceptor());
}
Is the reloadablemessagesource to blame somehow? 是reloadablemessagesource会以某种方式怪罪吗?
这解决了我的问题
resourceBundleMessageSource.setBasename("classpath:language");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.