0

I am trying to add escaped values to an error message in a Spring MVC Validator

final Object[] vatErrorArray = new String[2];
   vatErrorArray[0] = "aaa";
   vatErrorArray[1] = "bbb";
errors.rejectValue("vatfield", "vendor.vat.number.invalid.pattern.generic", vatErrorArray, "Invalid VAT");

where vendor.vat.number.invalid.pattern.generic is as follows:

vendor.vat.number.invalid.pattern.generic=VAT Number's pattern is invalid for {0}. Valid pattern: {1}.

Unfortunately, the displayed error message doesn't contain the escaped values:

VAT Numbers pattern is invalid for {0}. Valid pattern: {1}.

What am I doing wrong?

PS I am using Spring MVC version 4.2.1.RELEASE

1 Answers1

0

I think you need to change the single quote in Number's to two single quotes ('').

I haven't tried it myself but am basing this mostly on the content of this question, and the MessageFormat docs it links to, plus the fact that your single quote seems to be disappearing.

Community
  • 1
  • 1
DaveyDaveDave
  • 9,821
  • 11
  • 64
  • 77
  • 1
    Replacing the single quote in the message (_Number's_) by two double quotes (_Number''s_) solved the problem. Many thanks. – user3530997 Dec 17 '15 at 09:07