Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 有时速度并不能代替速度_Java_Velocity_Template Engine - Fatal编程技术网

Java 有时速度并不能代替速度

Java 有时速度并不能代替速度,java,velocity,template-engine,Java,Velocity,Template Engine,有时,以下代码会在模板中生成$position.getComment()。其他字段也一样。但这只是偶尔的行为。原因可能是什么?如何修复 #if($position.hasComment()) <td>$position.getComment()</td> #else <td class="empty">&mdash;</td> #end 在Velocity启动时,使用一些日志可能很有用 velocity - Velocim

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

#if($position.hasComment())
    <td>$position.getComment()</td>
#else
    <td class="empty">&mdash;</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">&mdash;</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">&mdash;</td>
#else
    <td>$position.getComment()</td>
#end