Grails,如果值为 0.0,则显示空白

Grails, display blank if value is 0.0

我希望包含数值 0.0 的字段显示为空白。 我怎样才能在 Grails 视图中做到这一点?

这是 gsp 代码:

<g:each in="${od.plannedVolumes}" status="j" var="pv">
       <td id="pv_center">${pv.volume}</td>
</g:each>

pv.volume 在域中声明为 Double。

利用 groovy truth 你可以输出一个非中断 space 如果归零。

<td id="pv_center">${pv.volume ?: '&nbsp'}</td>