freemarker 使用简单笔记

 

<#if myplanppScoreList.planeeMyList?exists && myplanppScoreList.planeeMyList?size gt 0>html

判断 list存在,并且长度大于0spa

 

计划完成时间:${planeeMy.hepplaneePo.planEtime?date} 将后台的 Date转为 年月日

 

freemarker的空值和默认值

 (2010-09-17 16:06:14)htm

转载▼对象

标签: 

杂谈

分类: it技术

Welcome ${user!}!
Welcome ${user!'your name'}!
或者blog

${user?if_exists}

${user?default('your name')}get


若是user找不到值,会输出
Welcome !
Welcome your name!it

不然freemarker会报错table

 

对象user,name为user的属性的状况,user,name都有可能为空,那么能够写成${(user.name)!''},表示user或者name为null,都显示为空。判断为空class

<#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>

相关文章
相关标签/搜索