freemarker学习常用指令

上传人:平*** 文档编号:12210343 上传时间:2017-10-17 格式:DOC 页数:5 大小:26.02KB
返回 下载 相关 举报
freemarker学习常用指令_第1页
第1页 / 共5页
freemarker学习常用指令_第2页
第2页 / 共5页
freemarker学习常用指令_第3页
第3页 / 共5页
freemarker学习常用指令_第4页
第4页 / 共5页
freemarker学习常用指令_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《freemarker学习常用指令》由会员分享,可在线阅读,更多相关《freemarker学习常用指令(5页珍藏版)》请在金锄头文库上搜索。

1、freemarker学习笔记常用命令1.条件语句 ifyour code注:if 后面跟的是判断条件,判断条件不能用$变量名的形式,直接用变量名就可以了2.条件判断语句 if else0)$I18n.getMessage(ForumBase.newPm): ($session.privateMessages)$I18n.getMessage(ForumBase.privateMessages)注:if else 语句跟普通的不同之处是在中间可以有多句代码,而不是只执行 if后面的一句代码3.嵌套条件判断语句 if if elseyour codeother code0)$I18n.getMes

2、sage(ForumBase.newPm): ($session.privateMessages)$I18n.getMessage(ForumBase.privateMessages)other code4.循环指令 listyou code4.嵌套循环指令 listyour code:$category.nameinner code:$category.forum.name$m_index + 1.$m.name?htmlother code注:as 后面是别名,在循环体中可直接用(类似 sql语句表的别名,以用指令提前结束 list循环。$m_index + 1.是取 list的索引,其中

3、 m_index为 list的下标,从 0开始。5.导入 macros指令 import使用:/6.定义变量指令 assign$m.name?html/其中 forumRepository.getModeratorList(forum.id)为变量 moderators的值$paginationData/其中为变量 paginationData的值7.改变(替换)变量指令 assign0)8.switch指令This will be processed if it is smallThis will be processed if it is mediumThis will be proces

4、sed if it is largeThis will be processed if it is neitheruserName: $userName等同于userName: $userName?html注:escape 指令在解析模版时起作用,而不是运行时起作用9.设置缺省格式指令 setting$1.234输出 1$1.234输出1.2310.包含文件指令 include除了相关的文本外,在 FreeMarker模板中可以包括下面三种特定部分:$:称为插补(interpolations),FreeMarker 会在输出时用实际值进行替代。指令:也叫 FreeMarker标记,与 HTML标记类似,但用#开始(有些以开始,在后面叙述)。注释:包含在(而不是)之间文本。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号