使用百里香格式化数字时出现问题

时间:2019-05-31 04:05:41

标签: html spring-boot thymeleaf

我在Thymeleaf中遇到数字格式问题。 我有一个html模板,该模板通过遍历每个账单显示账单数据。 在我的数据模型中,大多数字段为String类型,但brokerageRate字段为Double类型。 当我运行我的代码时,它给了我以下异常 评估SpringEL表达式的异常:“#numbers.formatDecimal(bill.brokerageRate,3,2)”

[{q1:[a,c]}, {q2:[a]}]

我尝试了Thymeleaf文档中提供的不同选项,但是我遇到了相同的例外。 https://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html

以下是我的模板:-

<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>

请您帮助我了解我在哪里错了。

1 个答案:

答案 0 :(得分:0)

这个怎么样?

th:text="${#numbers.formatDecimal({bill.brokerageRate},3,2)}"
相关问题