0

in jstl currency for matter is using http://java.sun.com/jsp/jstl/fmt.

Tag included as follows: <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

we are using as

<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)

is there is any way we can set round RoundingMode.HALF_UP ?

Any way to override the default behavior of [jstl fmt tag library] and giving support of rounding mode.

4

1 に答える 1

0

数値を別の方法で丸める標準formatNumberタグを取得できますか? 私の知る限り、いいえ。

ただし、次のいずれかを実行できます。

  • value最初に値を丸める関数を使用する式に属性を変更できます。例: JSP/EL で静的メソッドを呼び出す方法は?

  • 既存の Tag クラスを拡張し、別の方法で丸めを行うカスタム Tag を作成できます。問題は次のとおりです。

    • 実際のタグ クラス (およびその名前) は、使用している JSTL の実装によって異なります。したがって、カスタム Tag クラスも同様に特定の JSTL 実装に関連付けられます。

    • 既存のタグ クラスの実装は、拡張に適していない場合があります。

于 2013-10-25T13:44:06.723 に答える