1 / 23
文档名称:

FreeMarker开发指南.doc

格式:doc   大小:55KB   页数:23页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

FreeMarker开发指南.doc

上传人:wangzhidaol 2017/2/24 文件大小:55 KB

下载得到文件列表

FreeMarker开发指南.doc

相关文档

文档介绍

文档介绍:FreeMarke 开发指南 1 概念 2 指令 if, else, elseif switch, case, default, break list, break include press escape, noescape assign global setting macro, nested, return t, lt, rt3 一些常用方法或注意事项表达式转换类数字循环对浮点取整数给变量默认值判断对象是不是 null 常用格式化日期添加全局共享变量数据模型直接调用 java 对象的方法字符串处理( 内置方法) 在模板里对 sequences 和 hashes 初始化注释标志 sequences 内置方法 hashes 内置方法 4 freemarker 在 web 开发中注意事项 web 中常用的几个对象 view 中值的搜索顺序在模板里 ftl 里使用标签如何初始化共享变量与 webwork 整合配置 5 高级方法自定义方法自定义 Transforms 1 概念最常用的 3 个概念 sequence 序列,对应 java 里的 list 、数组等非键值对的集合 hash 键值对的集合 namespace 对一个 ftl 文件的引用, 利用这个名字可以访问到该 ftl 文件的资源 2 指令 if, else, elseif 语法<#if condition> ... <#elseif condition2> ... <#elseif condition3> ... ... <#else> ... </#if> 用例<#if x= 1> x is1 </#if> <#if x= 1> x is1 <#else> x is not 1 </#if> switch, case, default, break 语法<#switch value> <#case refValue1> ... <#break> <#case refValue2> ... <#break> ... <#case refValueN> ... <#break> <#default> ... </#switch> 用例字符串<#switch > <#case "small"> This will be processed if it is small <#break> <#case "medium"> This will be processed if it is medium <#break> <#case "large"> This will be processed if it is large <#break> <#default> This will be processed if it is neither </#switch> 数字<#switch x> <#case x= 1> 1 <#case x= 2> 2 <#default> d </#switch> 如果 x=1 输出 1 2, x=2 输出 2, x=3 输出 d list, break 语法<#list sequence as item> ... <#if item = "spring"><#break></#if> ... </#list> 关键字 item_index: 是 list 当前值的下标 item_has_next: 判断 list 是否还有值用例<#assign seq = ["winter", "spring", "summer", "autumn"]> <#list seq as x> ${x_index + 1}. ${x}<#if x_has_next>,</#if> </#list> 输出 1. winter, 2. spring, 3. summer, 4. autumn include 语法<#include filename> or <#include filename options> options 包含两个属性 encoding= ” GBK ”编码格式 parse=true 是否作为 ftl 语法解析, 默认是 true , false 就是以文本方式引入. 注意在 ftl 文件里布尔值都是直接赋值的如 parse=true, 而不是 parse= ” true ”用例/common/ 包含内容 Copyright 2001-2002 ${me}<br> All rights reserved. 模板文件<#assign me = "Juila Smith"> <h1>Some test</h1> <p>Yeah. <hr> <#include "/common/"