FreeMarker:期望一个布尔值,但是这被评估为一个数字

时间:2014-02-17 10:06:19

标签: java template-engine freemarker

我有一个模板,我可以这样做:

<#if result.numFound > 10> 
  (some data)
</#if>

这给了我解析错误:

For "#if" condition: Expected a boolean, but this evaluated to a number

result.numFoundInteger。 我读过documentation,也许我错过了什么......

1 个答案:

答案 0 :(得分:8)

你错过了文档中的最后几行:)。

How to test if x is greater than 1? <#if x > 1> will be wrong, as FreeMarker will 
interpret the first > as the end of the tag. Thus, either write <#if (x > 1)> or <#if x &gt; 1>.