we use Spring MessageSource to create error messages in our application.
We fill out our error messages as follows
dobInvalid = The DOB supplied {0} is invalid
We want to use named parameters so that we can do
dobInvalid = The DOB supplied {dob} is invalid
Looking at the Api docs for getMessage, it looks like you can do this http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/context/MessageSource.html
args - an array of arguments to be filled for the parameters within the message (the parameters look like "{0}", "{1, date}", "{2, time}" within the message), or null if not.
Obviously, we can write our own, but it was interesting if Spring could do this, and if anyone could provide an example or use named parameters rather than positional parameters.
Cheers Mark
source share