Can't convert boolean to string automatically, because the "boolean_format" setting w

如题,使用freemarker作为模板引擎,当我们的变量类型为boolean时,如果通过freemarker页面直接输出,会报错。

Can't convert boolean to string automatically, because the "boolean_format" setting was "true,false", which is the legacy default computer-language format, and hence isn't accepted.

----
Tip: If you just want "true"/"false" result as you are generting computer-language output, use "?c", like ${myBool?c}.
----
Tip: You can write myBool?string('yes', 'no') and like to specify boolean formatting in place.
----
Tip: If you need the same two values on most places, the programmers should set the "boolean_format" setting to something like "yes,no".
----

解决办法在提示里面,我们需要对boolean类型做一个转换:${status?string("ok","error")}

Can't convert boolean to string automatically, because the "boolean_format" setting w

转换之后,页面显示就正常了,不会报错:

Can't convert boolean to string automatically, because the "boolean_format" setting w

string("ok","error"),这里可以随便替换,就是需要两个参数,可以根据实际需要,当然,写成string("true","false")也是可以的。

上一篇:easymock的用法


下一篇:关于H5唤醒APP的功能实现