3
如果可能由Spring自动解析嵌套属性,我需要帮助。我使用Spring 4.2.4,Java的8和属性文件看起来喜欢 -ResourceBundleMessageSource中的嵌套属性
# messages.properties
company.name=XYZ
welcome.message=Dear Customers of ${company.name}
about.company=${company.name} is blah blah
我们有一个自定义的本地化实现摆脱资源包I18字符串为如下─
public String get(Locale locale, String key, Object... arguments) {
String pattern = this.getString(locale, key);
MessageFormat formatter = new MessageFormat(pattern, locale);
StringBuffer buffer = new StringBuffer();
formatter.format(arguments, buffer, null);
return buffer.toString();
}
定义我希望能够像get(locale,“welcome.message”)一样使用此方法,并期望将其呈现为XYZ的尊敬的客户。
目前它没有在MessageFormat中失败。有没有办法让spring自动解决这个问题。
感谢您的答复等。因此对于上述属性文件设置,您将如何解决“XYZ的尊敬的客户”。信息。 – novice
你调用String name = getMessage(“company.name”,null);然后String message = getMessage(“welcome.message”,name) – novice
我喜欢** {0} **的亲爱的客户,或者尝试发送公司作为参数 – user2669657