【发布时间】:2014-04-14 11:23:59
【问题描述】:
有时以下代码会在模板中生成$position.getComment()。其他领域也一样。但这是偶尔的行为。可能是什么原因以及如何解决?
#if($position.hasComment())
<td>$position.getComment()</td>
#else
<td class="empty">—</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.
【问题讨论】:
-
发生这种行为时
comment的值是多少?您是否在渲染模板之前设置上下文?
标签: java velocity template-engine