开始以下面的方式定义:
<#assign configArr[] />
<#assign configArr[0]=['北京','010']/>
<#assign configArr[1]=['上海','021']/>
<#list configArr as it>
${it[0]} ${it[1]}
</#list>
报错:
[color=red]Exception in thread "main" freemarker.core.ParseException: Encountered "[" at line 1, column 19 in freemarker.ftl.
Was expecting one of:
"=" ...
"in" ...
">" ...[/color]
解决:
<#assign configArr = [
['北京','010'],
['上海','021']
] >
<#list configArr as it>
${it[0]} ${it[1]}
</#list>
正确输出了:
北京 010
上海 021
<#assign configArr[] />
<#assign configArr[0]=['北京','010']/>
<#assign configArr[1]=['上海','021']/>
<#list configArr as it>
${it[0]} ${it[1]}
</#list>
报错:
[color=red]Exception in thread "main" freemarker.core.ParseException: Encountered "[" at line 1, column 19 in freemarker.ftl.
Was expecting one of:
"=" ...
"in" ...
">" ...[/color]
解决:
<#assign configArr = [
['北京','010'],
['上海','021']
] >
<#list configArr as it>
${it[0]} ${it[1]}
</#list>
正确输出了:
北京 010
上海 021