Freemarker 中的布尔类对象

发布于 2025-01-13 20:52:38 字数 125 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2025-01-20 20:52:38

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 the Boolean object is exposed through a method like public Boolean isSomething(), instead of public Boolean getSomething(). According the Java Beans rules (which aren't defined by FreeMarker), you can only use an "is" read-method for boolean properties, not for Boolean properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文