<fmt:formatNumber in jstl need to $ symbol
Solution 1
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:
Solution 2
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.
Solution 3
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"/>
Santhosh
I'm so eager to learn new stuff's and to work in cutting edge technologies. I have around 4 years of experience in various technologies like Java, Asp.Net MVC, Javascript frameworks.
Updated on June 04, 2022Comments
-
Santhosh almost 2 years
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 Advance!!!