关于FreeMarker的list循环取值问题
我定义${item[0].items[0].name}可以正常取items[0]的name值,但是我要是循环遍历items中的name值,即<#listitem[0].i...
我定义${item[0].items[0].name}可以正常取items[0]的name值,但是我要是循环遍历items中的name值,即
<#list item[0].items as x>
var listArray = [];
listArray[${x_index}] = "${(x.name)!""}";
</#list>
就会报错
Expected collection or sequence. item[0].items evaluated instead to freemarker.template.SimpleHash on line 81, column 24 in index.ftl.
想知道这个怎么操作?谢谢
我改为<#list ${item[0].items} as x>报的是这个错误:
Exception in thread "main" freemarker.core.ParseException: Encountered "{" at line 81, column 25 in index.ftl.
Was expecting one of:
"as" ...
"." ...
"[" ...
"(" ...
"?" ...
"!" ...
<TERMINATING_EXCLAM> ... 展开
<#list item[0].items as x>
var listArray = [];
listArray[${x_index}] = "${(x.name)!""}";
</#list>
就会报错
Expected collection or sequence. item[0].items evaluated instead to freemarker.template.SimpleHash on line 81, column 24 in index.ftl.
想知道这个怎么操作?谢谢
我改为<#list ${item[0].items} as x>报的是这个错误:
Exception in thread "main" freemarker.core.ParseException: Encountered "{" at line 81, column 25 in index.ftl.
Was expecting one of:
"as" ...
"." ...
"[" ...
"(" ...
"?" ...
"!" ...
<TERMINATING_EXCLAM> ... 展开
1个回答
2013-09-29
展开全部
去看看freemarker表达式怎么用的就知道了,看是否正确,或者和其他表示方式有冲突吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询