背景:ftl模板工具類Template,在使用ftl模板生成數據時的問題彙總。
1、list對象數據遍歷(&爲根據模板生成數據後的分割符)
<#list datas as listData >
<#if listData.targetType == 'type'>
{
"age":"0",
"Name":"${listData.Name!}"
}&
</#if>
</#list>
2、${}嵌套取值及三元運算
${((listData.image)??)?string('http://127.0.0.1:8080'+'${lisimagetData.image}','')}""PicUrl":"${((listData.image)??)?string('http://127.0.0.1:8080'+'${listDaimageta.image}','')}
持續更新中…