Freemarker简单语法

Freemarker页面静态化技术简单语法:

**<#assign name="XX>** :在页面定义一个变量;

**${name}** :读取名称为name的变量;

**<#include “xxx.ftl”>** :用于模板文件的嵌套;

**<#if>...<#else>** :if  else判断语句;

**<#list userList as user>** :遍历名称为userList的集合;

**<#userList ?size>** :获取userList 集合的长度;

**<#assign data=user?eval>** :把json字符串转为对象;

**${math?c}** :把数据转为字符串;

**${today?datetime}** :把date类型转换为日期+时间;

** ${today?string("yyyy 年 MM 月")} ** :日期格式化;

**<#if aaa??> ** :判读变量aaa是否存在,存在返回true,否则返回false;

** ${aaa!' bbb'} ** :,当 aaa 为 null 则返回!后边的内容;

以上语法命令,基本可以满足模板的基本书写;

猜你喜欢

转载自blog.csdn.net/XuYuanChong/article/details/87741841