问题描述
我正在使用formatNumber,如下所示:
I'm using formatNumber as follows:
<fmt:formatNumber value="${amount}" type="currency" currencyCode="${currencyCode}" var="amt" />
如果我在locale en_US且货币代码是EUR,我会得到 EUR
作为符号,但如果我在locale en_GB,我得到€
。为什么要考虑区域设置?欧元不应该总是兑换成€
?反正有没有得到我期望的行为 formatNumber
?
If I'm in locale en_US and the currency code is EUR I get EUR
as the symbol, but if I'm in locale en_GB I get €
. Why is the locale taken into account? Shouldn't EUR always convert into €
? Is there anyway to get the behavior I'm expecting using formatNumber
?
推荐答案
Locale被带入acount,因此输出对用户有意义。
Locale is taken into acount so the output makes sense to the user.
作为一个愚蠢的美国人(住在en_US语言环境中),我不知道那个时髦的符号是什么意思。
As a silly American (who lives in the en_US locale) I have no idea what that funky symbol means.
欧元对我来说非常有意义。
EUR makes perfect sense to me.
A 建议您可以将 currencySymbol
属性设置为您想要的任何内容:
A quick google suggests you can set the currencySymbol
attribute to whatever you want:
<fmt:formatNumber value="${amount}" type="currency" currencySymbol="FOO" currencyCode="${currencyCode}" var="amt" />
这篇关于为什么设置currencyCode时jstl的formatNumber货币符号区域设置是特定的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!