【问题标题】:Casting int to float in thymeleaf frontend铸造 int 以漂浮在 thymeleaf 前端
【发布时间】:2016-09-06 13:35:34
【问题描述】:

我有这样的事情:

<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'">

【问题讨论】:

    标签: java spring casting thymeleaf


    【解决方案1】:

    答案很简单:

    将(至少)其中一个数字与浮点数相乘,例如1.0.

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      相关资源
      最近更新 更多