关于freeMarker得到list长度的问题

 

取得list的长度:${fields?size}

 

而使用判断其长度的时候,

 

<#if fields?size>0 >

 

竟抛出错了,说不是boolean类型,

 

Java backtrace for programmers:

----------

freemarker.core.NonBooleanException: Error on line 132, column 22 in viewEntity_js.ftl

Expecting a boolean (true/false) expression here

Expression fields?size does not evaluate to true/false

it is an instance of freemarker.template.SimpleNumber

         at freemarker.core.Expression.isTrue(Expression.java:150)

 

晕,试了几下,原来加个刮号就没问题了。

 

<#if (fields?size>0) >

 

 

 

你可能感兴趣的:(freeMarker,freemarker,list,java)