gpt4 book ai didi

java - 有时速度并不能替代

转载 作者:太空宇宙 更新时间:2023-11-04 14:57:13 25 4
gpt4 key购买 nike

有时,以下代码会在模板中生成 $position.getComment()。其他领域也一样。但这只是偶尔的行为。可能是什么原因以及如何解决?

#if($position.hasComment())
<td>$position.getComment()</td>
#else
<td class="empty">&mdash;</td>
#end

职位的评论是字符串,下面是hasComment

public boolean hasComment() {
return comment != null;
}

一些日志可能在 Velocity 启动时有用

velocity - Velocimacro : allowInline = true : VMs can be defined inline in templates
velocity - Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
velocity - Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed.

Velocity templates not substituting methods

最佳答案

尝试这样做:

#if (! $position.getComment() || "$position.getComment()" == "")
<td class="empty">&mdash;</td>
#else
<td>$position.getComment()</td>
#end

我是速度方面的新手,所以我无法完全解释为什么,但我已经为一个新项目编写了一些 HTML 模板两周了,在我的团队中,我们发现这种方式是最好的方式去做这件事。

关于java - 有时速度并不能替代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23058808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com