The*_*iot 6 formatting jsp jstl variable-assignment
我在JSTL使用中创建变量
<c:set var="billableTime" value="${ps.computedAmount}" />
Run Code Online (Sandbox Code Playgroud)
我的问题是ps.computedAmount不是一个2位小数,我希望ps.computedAmount在分配之前将其四舍五入为2位小数billableTime.我知道如何在显示2位数字JSTL用
<fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${ps.computedAmount}" />
Run Code Online (Sandbox Code Playgroud)
但我的问题是为JSTL变量分配一个2位数值.
Cha*_*the 15
我想你可以这样做:
<c:set var="billableTime"><fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${ps.computedAmount}" /></c:set>
Run Code Online (Sandbox Code Playgroud)
小智 7
<fmt:formatNumber var="formattedBillableTime" type="number" minFractionDigits="2" maxFractionDigits="2" value="${ps.computedAmount}" />
<c:set var="billableTime" value="${**formattedBillableTime**}" />
Run Code Online (Sandbox Code Playgroud)