Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.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
Templates apachevelocity-if子句_Templates_If Statement_Apache Velocity - Fatal编程技术网

Templates apachevelocity-if子句

Templates apachevelocity-if子句,templates,if-statement,apache-velocity,Templates,If Statement,Apache Velocity,我使用apachevelocity创建电子邮件模板。 我有一封邮件,其中包含一个包含元素列表的表,为了创建它,我使用了#foreach 在此表中,我将添加一个包含条件字符串的列,如果元素为空,则字符串为string1如果不为空,则为string2 这是我的代码: #foreach( $item in $list ) <td style="max-width: 140px; word-wrap: break-word;"> #if(${value} n

我使用
apachevelocity
创建电子邮件模板。 我有一封邮件,其中包含一个包含元素列表的表,为了创建它,我使用了
#foreach

在此表中,我将添加一个包含条件字符串的列,如果元素为空,则字符串为
string1
如果不为空,则为
string2

这是我的代码:

 #foreach( $item in $list )
        <td style="max-width: 140px; word-wrap: break-word;">
        #if(${value} not null) 'String1' #else 'String2'#end</td>
 #end
 org.apache.velocity.runtime.parser.ParseException: Encountered "null" at line 25, column 131. Was expecting one of:
    "[" ...
    "{" ...
    "(" ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <IDENTIFIER> ...
    "{" ...
    "[" ...
        at org.apache.velocity.runtime.parser.Parser.generateParseException(Parser.java:3679)
#foreach($list中的项目)
#如果(${value}不为null)'String1'#否则'String2'#结束
#结束
错误日志

 #foreach( $item in $list )
        <td style="max-width: 140px; word-wrap: break-word;">
        #if(${value} not null) 'String1' #else 'String2'#end</td>
 #end
 org.apache.velocity.runtime.parser.ParseException: Encountered "null" at line 25, column 131. Was expecting one of:
    "[" ...
    "{" ...
    "(" ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <IDENTIFIER> ...
    "{" ...
    "[" ...
        at org.apache.velocity.runtime.parser.Parser.generateParseException(Parser.java:3679)
org.apache.velocity.runtime.parser.ParseException:在第25行第131列遇到“null”。我期待的是:
"[" ...
"{" ...
"(" ...
...
“真的”。。。
“假”。。。
...
...
...
"{" ...
"[" ...
位于org.apache.velocity.runtime.parser.parser.generateParseException(parser.java:3679)

我在stack中找不到任何帮助…有人可以帮助我吗?

我认为这可以在您的情况下运行:

#if( $value)
    <td style="max-width: 140px; word-wrap: break-word;">String1</td>
#else
    <td style="max-width: 140px; word-wrap: break-word;">String2</td>
#end
#如果($value)
String1
#否则
String2
#结束
试着读一下这个