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 “模板名称”>

相关文章
相关标签/搜索