TheCoder
TheCoder

Reputation: 8913

How is fmt:formatNumber tag used?

I am trying to format a percentage to 2 decimal places and the code (below) I am using is not working:

<form:input 
     class="calculator-percentage-input"
     value="<fmt:formatNumber value='${percentage}' maxFractionDigits='2' />"
     path="discount" cssErrorClass="error"
/>

The value displayed in my input box is (percentage is empty):

<form:input 
     class="calculator-percentage-input"
     value="" 
     path="discount" cssErrorClass="error"
/>

Can anyone tell me how to just display the value of percentage?

Upvotes: 0

Views: 3250

Answers (1)

TheCoder
TheCoder

Reputation: 8913

Solution:

<fmt:formatNumber var='myDiscountPercentage' value='${discountPercentage}'     maxFractionDigits='2'/>

<form:input 
     class="calculator-percentage-input"
     value="${myDiscountPercentage}"
     path="discount" cssErrorClass="error"
/>

Upvotes: 3

Related Questions