开发者

<fmt:formatNumber in jstl need to $ symbol

In our struts app, we have been using <fmt:formatNumber> is so many places to show currency. By default the tag takes browser setting and showing the currency symbol. If locale is "en_US" showing ($), if "en_UK" showing (euro).

But I want to show dollar alone to my whole application. Is there any way to change in single place to reflects.

Thanks in Adva开发者_开发技巧nce!!!


But I want to show dollar alone to my whole application.

Just specify the currencySymbol attribute.

<fmt:formatNumber type="currency" currencySymbol="$" value="${product.price}" />

See also:

  • <fmt:formatNumber> tag documentation


In <fmt:setLocale value="en_US"/>, you can use scope attribute and put value to application. By that way, it will save Locale value to en_US for the whole application.


I'm assuming you're using properties file. I would suggest having a properties file based on the language locale instead of country locale.

E.g. If you have ApplicationResource.en_US.properties and ApplicationResources.en_UK.properties, rather have ApplicationResources.en.properties and have a key/value entry that displays only dollar.

Alternatively, you would set your locale to only en_US before displaying your currency. Example:

<fmt:setLocale value="en_US"/>
<fmt:formatNumber value="${val}"
                  type="currency"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜