问题
I have something like this:
<span th:text="*{a / (b + c)}"></span>
where a, b and c are integers. I need the result to be a floating point number.
Any ideas?
Actual code:
<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:
The answer is simple:
Multiply (at least) one of the numbers with a float e.g. 1.0
.
<span th:text="*{ (a * 1.0) / (b + c)}"></span>
来源:https://stackoverflow.com/questions/39350392/casting-int-to-float-in-thymeleaf-frontend