messageSource不替换模板中的所有参数

时间:2017-11-10 14:35:00

标签: java spring internationalization template-engine resourcebundle

我有代码:

messageSource.getMessage("some.key",new Object[]{30,31},Constants.LOCALE)

和键内部属性文件:

some.key=Csv header length ({0}) doesn't correspond the mapping file size {1} .

但结果很奇怪:

Csv header length (30) doesn't correspond the mapping file size {1} .

Fisrt变量被成功替换,但第二次 - 不是。

为什么第二个参数没有解决?

1 个答案:

答案 0 :(得分:8)

问题是因为您在邮件中有一条未引用的单引号。

有关问题的示例,请参阅https://www.mscharhag.com/java/resource-bundle-single-quote-escaping