freemarker xml标签取值判断
1、如果为空,则就是空串
2、如果长度超过40 ,截取到40
3、如果长度没超过40,正常取值即可
这个表达式怎么表达才是最好的
<#if goods.insuranceGb?default("")>${(goods.insuranceGb)?substring(1,40)}<#else>${goods.insuranceGb}</#if>\n"
${(goods.insuranceGb!'')?substring(0, min(goods.insuranceGb!'', 40)?length)}
谢谢了,用这个方法会报错,我用这种格式的就可以了
<#if myOptionalVar??>when-present<#else>when-missing</#if>