<#if myplanppScoreList.planeeMyList?exists && myplanppScoreList.planeeMyList?size gt 0>
判断 list存在,而且长度大于0
计划完成时间:${planeeMy.hepplaneePo.planEtime?date} 将后台的 Date转为 年月日
freemarker的空值和默认值
(2010-09-17 16:06:14)
转载▼
标签: 杂谈 | 分类: it技术 |
Welcome ${user!}!
Welcome ${user!'your name'}!
或者
${user?if_exists}
${user?default('your name')}
如果user找不到值,会输出
Welcome !
Welcome your name!
否则freemarker会报错
对象user,name为user的属性的情况,user,name都有可能为空,那么可以写成${(user.name)!''},表示user或者name为null,都显示为空。判断为空
<#if (user.name)??>
……
</#if>
比如默认值为 0
${(toDoStList.notProcessed)!'0'}
<#if plan.monthlyPfmcePlanName?exists>
${plan.monthlyPfmcePlanName}
</#if>
exists 使用 在对象 里面, 不能使用 在 list 对象的, 应该判断 长度
例子:
<#if myplanppScoreList.hrEffPfmcePlanPo?exists && myplanppScoreList.hrEffPfmcePlanPo?size gt 0>
<#list myplanppScoreList.hrEffPfmcePlanPo as plan>
<#if plan?exists>
<span class="year" style="width:250px;text-align:left; float:left;">
<#if plan.monthlyPfmcePlanName?exists>
${plan.monthlyPfmcePlanName}
</#if>
</span>
</#if>
</#list>
</#if>