freemarker 日常使用遇到的标签

记录:

从java后台传json字符串到前台ftl中,

形如

{"sign":{"signValPosition":"1","keySignName":"Sign11","arraySigns":[{"signMode":"1001","signSequence":"1","signType":"TOUPPERCASE","signSecretKey":""},{"signMode":"1001","signSequence":"2","signType":"BASE64","signSecretKey":""},{"signMode":"1002","keyIsBefore":1,"signSequence":"3","signType":"MD5_16SIGN","signCharEncode":"UTF-8","signSecretKey":"abc123"}]},"encry":{"arraySigns":[{"signMode":"1001","signSequence":"1","signType":"BASE64","signSecretKey":""},{"signMode":"1002","keyIsBefore":1,"signSequence":"2","signType":"MD5_16SIGN","signCharEncode":"UTF-8","signSecretKey":"abc123456"},{"signMode":"1003","secretIsBefore":1,"signSequence":"3","signType":"AES_128ARITH","signCharEncode":"UTF-8","signSecretKey":"suning123456"}]}}

使用ftl标签

<#assign text>
		${bean.supplierEncryptWay}(这个就是json字符串)

<#assign json=text?eval />
如果仅仅获取${json.sign}则会报错的。
这里必须得获取到指定的节点中
${json.sign.signValPosition}  则返回1
如果获取json里面的数组
<#list json.sign.arraySigns as item>
		${item.signMode}, ${item.signSequence},${item.signType}

freemarker 日常使用遇到的标签_第1张图片

判断json中的某个节点是否存在

<#if json.sign??> 
	不为空
    

 

你可能感兴趣的:(前端种种)