我正在尝试将百分比格式化为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
的价值吗?
答案 0 :(得分:3)
解决方案:
<fmt:formatNumber var='myDiscountPercentage' value='${discountPercentage}' maxFractionDigits='2'/>
<form:input
class="calculator-percentage-input"
value="${myDiscountPercentage}"
path="discount" cssErrorClass="error"
/>