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

messageSource doesn't replace all arguments in template

我有代码:

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} .

第一个变量已成功替换,但第二个 - 没有。

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

问题是因为你的消息中有一个单引号你没有转义

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