gstackoverflow
gstackoverflow

Reputation: 36984

messageSource doesn't replace all arguments in template

I have code:

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

and key inside property file:

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

but result is strange:

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

Fisrt variable was successfully replaced but second - not.

Why does second argument was not resolved?

Upvotes: 6

Views: 6033

Answers (1)

adamcooney
adamcooney

Reputation: 398

The problem is because you have a single quote in the message that you have not escaped.

See https://www.mscharhag.com/java/resource-bundle-single-quote-escaping for an example of your problem.

Upvotes: 17

Related Questions