Freemarker:表达式中的表达式
Freemarker : Expression inside Expression
有什么方法可以在 Freemarker 的表达式中使用表达式吗?
示例:
XML 文件
<Document>
<Row>
<item_date>01/01/2015</item_date>
</Row>
<Row>
<item_date>02/01/2015</item_date>
</Row>
</Document>
<#list 0..1 as i>
${Document.Row[${i}].item_date}
</#list>
我要打印如下
2015 年 1 月 1 日
2015 年 2 月 1 日
有什么想法吗?
提前致谢
像这样:
${Document.Row[i].item_date}
请注意,如果您使用的是最新版本,则会收到此错误消息,其中解释了原因:
You can't use "${" here as you are already in
FreeMarker-expression-mode. Thus, instead of ${myExpression}, just
write myExpression. (${...} is only needed where otherwise static text
is expected, i.e, outside FreeMarker tags and ${...}-s.)
有什么方法可以在 Freemarker 的表达式中使用表达式吗?
示例: XML 文件
<Document>
<Row>
<item_date>01/01/2015</item_date>
</Row>
<Row>
<item_date>02/01/2015</item_date>
</Row>
</Document>
<#list 0..1 as i>
${Document.Row[${i}].item_date}
</#list>
我要打印如下 2015 年 1 月 1 日 2015 年 2 月 1 日
有什么想法吗?
提前致谢
像这样:
${Document.Row[i].item_date}
请注意,如果您使用的是最新版本,则会收到此错误消息,其中解释了原因:
You can't use "${" here as you are already in FreeMarker-expression-mode. Thus, instead of ${myExpression}, just write myExpression. (${...} is only needed where otherwise static text is expected, i.e, outside FreeMarker tags and ${...}-s.)