spring message tag with multiple arguments
The cause of the probelm is that ,
(comma) is the default separator. So at the end the spring message tag will get the String A,B,C,D,E,F
for parameter arguments
, and it will split this string into 6 different internal arguments for the message.
You must change the separator. If you use ;
for example, then it will work.
<spring:message code="messageCode" arguments="${value1};${value2};${value3}" htmlEscape="false" argumentSeparator=";"/>
You could also send the different values as an array and leave no room for spring making a mistake in how to parse the string argument.
<c:set var="value1" value="A,B;X" /><c:set var="value2" value="C,D;Y" /><c:set var="value3" value="E,F;Z" /><spring:message code="messageCode" arguments="${[value1, value2, value3]}" htmlEscape="false" />
This way you need no worry about your new separator somehow being used in a value at some point again.
I use completely different approach. My database-based message source is exposed in my config with the name i18n:
@Bean(name = {"i18n", "messageSource"})public MessageSource messageSource() { return new JpaMessageSource();}
and I also expose my beans with viewResolver.setExposeContextBeansAsAttributes(true);
After that I can use ${i18n.message("messageCode", value1, value2, value3)}
in my jsp-views.