spring - fmt formatNumber 类型 ="currency"显示 "¤"而不是实际的货币符号

标签 spring jstl currency-formatting

我有以下代码将金额显示为货币:

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

相关文章:

java - 从 DAO 获取值以在 JSP 中使用

javascript - Highcharts y轴千位分隔符

java - 带有可选查询字符串的 Spring RESTful url

java - Java Web应用程序中的多个数据库连接

java - JSTL 标签从数据类打印在 JSP 中

java - JSF 'total' 变量类似于 c :set in JSTL

spring - Spring Boot + Spring Security 应用程序中 POST/PUT/DELETE 请求的 403 响应

java - Shiro 独立应用程序

php - 在 MySQL 和 PHP 中处理货币时如何处理精度

sap-commerce-cloud - 在hybris中设置货币格式