2013-10-25 26 views
0

爲物質使用http://java.sun.com/jsp/jstl/fmt。包括如何在JSTL貨幣延長JSTL fmt標記庫

標記如下: <%@標籤庫URI = 「http://java.sun.com/jsp/jstl/fmt」 前綴= 「FMT」 %>

我們使用作爲

<fmt:formatNumber maxFractionDigits="0" currencySymbol="$" type="currency" value="${employeeDetail.employee.annualSalary }" /> 


Now behavior is : 

Ex: $470.161 is round to $470.16) 
Ex: $470.165 is round to $470.16) 
Ex: $470.166 is round to $470.17) 

what is expected uis 
Ex: $470.161 is round to $470.16) 
Ex: $470.165 is round to $470.17) 
Ex: $470.166 is round to $470.17) 

是否有任何方法我們可以設置輪RoundingMode.HALF_UP

任何方式覆蓋[JSTL fmt標記庫],並給予支持舍入模式的默認行爲。

回答

0

你能得到標準formatNumber標籤數字的舍入不同?據我所知,第

但是你可以做以下之一:

  • 你可以改變value屬性到使用功能首輪值的表達式;例如How to call a static method in JSP/EL?

  • 您可以創建一個擴展現有的標籤類,並做了四捨五入不同的自定義標籤。該障礙是:

    • 實際標記類(及其名稱)取決於您正在使用的JSTL的實現。因此,您的自定義Tag類也將與特定的JSTL實現綁定。

    • 現有的標籤類實現可能不適合擴展。