Java 有时速度并不能代替速度
有时,以下代码会在模板中生成Java 有时速度并不能代替速度,java,velocity,template-engine,Java,Velocity,Template Engine,有时,以下代码会在模板中生成$position.getComment()。其他字段也一样。但这只是偶尔的行为。原因可能是什么?如何修复 #if($position.hasComment()) <td>$position.getComment()</td> #else <td class="empty">—</td> #end 在Velocity启动时,使用一些日志可能很有用 velocity - Velocim
$position.getComment()
。其他字段也一样。但这只是偶尔的行为。原因可能是什么?如何修复
#if($position.hasComment())
<td>$position.getComment()</td>
#else
<td class="empty">—</td>
#end
在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.
尝试这样做:
#if (! $position.getComment() || "$position.getComment()" == "")
<td class="empty">—</td>
#else
<td>$position.getComment()</td>
#end
#if(!$position.getComment()||“$position.getComment()”==”)
&mdash;
#否则
$position.getComment()
#结束
我是velocity新手,所以我无法完全解释原因,但我已经为一个新项目编写了两周的HTML模板,在我的团队中,我们发现这种方法是最好的方法。当出现这种行为时,
注释
有什么价值?是否在呈现模板之前设置上下文?
#if (! $position.getComment() || "$position.getComment()" == "")
<td class="empty">—</td>
#else
<td>$position.getComment()</td>
#end