【问题标题】:How to Display Currency Symbols in Thymeleaf?如何在 Thymeleaf 中显示货币符号?
【发布时间】:2018-11-09 23:36:04
【问题描述】:

我正在准备产品报价,所以我想在我的 Thymeleaf 模板中显示货币符号

我在这个网站https://www.ip2currency.com/currency-symbol使用unicode value(HEX)作为货币符号

我在我的 HTML 页面中写了 <p th:utext="${currencySymbol}"/> 来显示货币符号,但它不起作用,这里 currencySymbol 是我的百里香变量,它的值是 ₹,我正在使用 Spring Boot

请帮助我,如何使用 Unicode 在百里香模板中显示货币符号

【问题讨论】:

  • 如果您不想使用该网站上的符号,您可以将我(错误地)投反对票的答案视为一种解决方法:stackoverflow.com/questions/14160304/…
  • 否则,您可能需要将ThymeleafViewResolver上的contentType设置为UTF-8
  • Unicode 值来自数据库,不同的货币会有不同的 Unicode 值所以我需要显示它。请你能告诉我我必须如何以及在哪里(在哪个文件中)设置 ThymeleafViewResolver ?
  • 您用 iText 标记了您的问题,但我在您关于 PDF 的问题中没有看到任何内容?仅关于 H​​TML?请澄清。
  • 从生成的 Thymeleaf 模板我使用 IText 创建它的 PDF 文件

标签: spring-mvc spring-boot thymeleaf jhipster


【解决方案1】:

这样使用

<span th:utext="${'$'+' '}" ></span></b><span th:text="${p.price}"></span> 它写在一个跨度标签内 一个货币跨度(美元的 html)和另一个跨度标签从 db 显示价格

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    相关资源
    最近更新 更多