在Thymeleaf前端中将整数转换为浮点数

3

我有类似这样的东西:

<span th:text="*{a / (b + c)}"></span>

其中a、b和c是整数。我需要结果为浮点数。

有什么想法吗?

实际代码:

<span th:text="(*{item.candidates } > 0 and *{item.budgetSeats + item.taxSeats} > 0)?*{#numbers.formatDecimal(item.candidates / (item.budgetSeats + item.taxSeats),1,2, 'POINT')}:'N/A'">
1个回答

4
答案很简单:将至少一个数字与浮点数相乘,例如1.0
<span th:text="*{ (a * 1.0) / (b + c)}"></span> 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接