Freemarker 中的布尔类对象
在 FreeMarker 中,我传递一个类型为“Boolean”的变量,但在 ftl 中,该变量的计算结果不会为 true 或 false,但如果将变量传递为“boolean”,它会按预期工作。有没有办法在ftl.h中使用布尔对象变量?
In FreeMarker, i am passing a variable having type 'Boolean' but in ftl the variable does not evaluate to true or false, but if pass variable as 'boolean' it works as expected. Is there any way to use Boolean Object variable in ftl.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FreeMarker 当然支持
Boolean
。典型的问题是Boolean
对象是通过public Boolean isSomething()
等方法公开的,而不是public Boolean getSomething()
。根据 Java Beans 规则(不是由 FreeMarker 定义的),您只能对boolean
属性使用“is”读取方法,而不能对Boolean
属性使用。Boolean
is of course supported by FreeMarker. The typical problem is that theBoolean
object is exposed through a method likepublic Boolean isSomething()
, instead ofpublic Boolean getSomething()
. According the Java Beans rules (which aren't defined by FreeMarker), you can only use an "is" read-method forboolean
properties, not forBoolean
properties.