我的代码:
private ApplicationContext context;
@Autowired
public UserServiceImpl(ApplicationContext context) {
this.context = context;
}
...
Locale bundle = new Locale.Builder().setLanguage("ru").setRegion("RU").build();
String av = context.getMessage("avatar.path", null, bundle);
错误:
在语言环境“ru_RU”的代码“avatar.path”下找不到消息。
豆类.xml
<beans:bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<beans:property name="basename" value="messages"> </beans:property>
</beans:bean>
文件夹 src/main/resources/ 中的messages_ru_RU.properties
avatar.path = resources/image/avatar.jpg