我有以下代码将金额显示为货币:
<fmt:formatNumber type="currency" value="${camp.montoTotal}"/>
当我在 Eclipse 中运行应用程序时(实际上我使用的是 STS),它看起来不错:“$500”。 但是当我将 WAR 文件部署到服务器(在 Ubuntu LTS 14.04 上使用 Tomcat8)时,它显示“¤500”,即显示通用货币标记而不是实际符号。我尝试使用以下命令强制区域设置:
<META http-equiv="Content-Language" content="es-AR">
<fmt:setLocale value="es-AR"/>
但结果相同。为什么可以呢?
最佳答案
我终于找到答案了!!
最初我在 app-config xml 中配置了 messageSource bean。当我将其移至 applicationContext xml 时,问题就解决了。我必须这样做,因为在尝试使用 getMessage 函数访问 Controller 中的消息属性时也遇到了问题。
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
结论:messageSource 必须在应用程序上下文中配置,而不是在根配置 xml 中。
关于spring - fmt formatNumber 类型 ="currency"显示 "¤"而不是实际的货币符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35725747/