Freemarker模板語法

1.1.1.    訪問map中的key

${key}對象

 

1.1.2.    訪問pojo中的屬性

Student對象。學號、姓名、年齡string

 

${key.property}模板

1.1.3.    取集合中的數據

<#list studentList as student>date

${student.id}/${studnet.name}List

</#list>循環

1.1.4.    取循環中的下標

<#list studentList as student>map

       ${student_index}im

</#list>數據

1.1.5.    判斷

<#if student_index % 2 == 0>datetime

<#else>

</#if>

1.1.6.    日期類型格式化

當前日期${date?date}

當前時間${date?time}

當前日期和時間${date?datetime}

自定義格式${date?string("yyyyMM/dd HH:mm:ss")}

1.1.7.    Null值的處理

${val!「空值」} 加上!後跟默認值

<#if val??>

  val有值

<#else>

  val爲null

<#if>

1.1.8.    Include標籤

<#include 「模板名稱」>

相關文章
相關標籤/搜索