Question

Given a property file with the key

property.code=Text goes here {0}

And

discountPercentage = 5.0

When I do

<fmt:formatNumber value="${discountPercentage / 100}" var="discount"
      type="PERCENT" minFractionDigits="1" maxFractionDigits="1" />             
<spring:message code="property.code" arguments="${discount}"  />

Then then the spring messge tag strips the fraction digits and the % sign and just displays 5 instead of 5.0%

Can't figure out what's going on here .. I thought it would have just worked.

Was it helpful?

Solution

My guess is that your local makes the formatted value 5,0%, and not 5.0%. And the arguments attribute of the spring message tag expects a comma-separated list of arguments.

Try passing no delimiter at all, or a fake delimiter:

<spring:message code="property.code" arguments="${discount}" argumentSeparator="${null}" />

or

<spring:message code="property.code" arguments="${discount}" argumentSeparator="" />

or

<spring:message code="property.code" arguments="${discount}" argumentSeparator="fake" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top