关于freemarker:FreeMarker笔记

7次阅读

共计 404 个字符,预计需要花费 2 分钟才能阅读完成。

正文

<#-- 正文内容 -->

<#-- 
正文也能够
多行内容 
-->

根本应用

<html>
Hello ${name} 或,#{name}
</html>

if 判断

<#if age gt 10 >
    年龄大于 10
</#if>

lt 代替 <,lte 代替 <=,gt 代替 >,gte 代替 >=

遍历 List

<#list userList as user>
    昵称:${user.nickname}
</#list>

遍历 Map

<#list map?keys as key>
    ${map[key]}
</#list>

注:map 的 key 只反对 String 类型,不反对 int long 等。

assign 创立或替换一个顶层变量

<#assign name="Harlan">

I'm ${name}

<#assign info={"mobile":"xxxxxx","address":"china"} >

my mobile is ${info.mobile}, my address is ${info.address}

正文完
 0