0

我正在尝试将百分比格式化为小数点后 2 位,而我使用的代码(如下)不起作用:

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

我的输入框中显示的值为(百分比为空):

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

谁能告诉我如何只显示 的值percentage

4

1 回答 1

3

Solution:

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

<form:input 
     class="calculator-percentage-input"
     value="${myDiscountPercentage}"
     path="discount" cssErrorClass="error"
/>
于 2012-09-03T16:13:58.573 回答