Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format Spring:message argument

How can I format the arguments of my <spring:message>?

I have a message like this:

 message.myMessage=this is {0} my message {1} with {2} multiple arguments

My jsp has the following:

<spring:message code="message.myMessage" 
                arguments="<fmt:formatNumber value='${value1}' currencySymbol='$' type='currency'/>,${value2},${value3}" 
                htmlEscape="false"/>

which doesn't display value1, which is a number I would like formatted.

I am not sure I can add the fmt tag inside the argument list.

like image 604
blong824 Avatar asked Jul 01 '11 16:07

blong824


1 Answers

The arguments attribute of <spring:message> can contain JSP EL expressions, but not JSP tags.

Try un-nesting it. You can assign the result of <fmt:formatNumber> to a variable, e.g.

<fmt:formatNumber var="formattedValue1" value='${value1}' currencySymbol='$' type='currency'/>
<spring:message code="message.myMessage" arguments="${formattedValue1},${value2},${value3}" htmlEscape="false"/>
like image 174
skaffman Avatar answered Sep 16 '22 17:09

skaffman