Why is jstl's formatNumber currency symbol locale specific when setting currencyCode

与世无争的帅哥 提交于 2019-12-30 10:59:47

问题


I'm using formatNumber as follows:

<fmt:formatNumber value="${amount}" type="currency" currencyCode="${currencyCode}" var="amt" />

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?


回答1:


Locale is taken into acount so the output makes sense to the user.

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 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" />


来源:https://stackoverflow.com/questions/11419827/why-is-jstls-formatnumber-currency-symbol-locale-specific-when-setting-currency

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!