freemarker常用标签解释
标签一: if else
你可以使用if,elseif和else指令来条件判断是否越过模板的一个部分。这些condition-s必须计算成布尔值,否则错误将会中止模板处理。elseif-s和else-s必须出现在if的内部(也就是,在if的开始标签和技术标签之间)。if中可以包含任意数量的elseif-s(包括0个)而且结束时else是可选的。
<#if x == 1>
x is
</#if>
<#if x == 1>
x is
<#else>
x is not
</#if>
<#if x == 1>
x is
<#elseif x == >
x is
<#elseif x == >
x is
</#if>
<#if x == 1>
x is
<#elseif x == >
x is
<#elseif x == >
x is
<#elseif x == >
x is
<#else>
x is not nor nor nor
</#if>
当然你也可以嵌套使用
<#if x == 1>
x is
<#if y == 1>
and y is too
<#else>
but y is not
</#if>
<#else>
x is not
<#if y < 0>
and y is less than
</#if>
</#if>
2 switch,case,default,break指令
<#switch being.size>
<#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>
3 list,break 指令
<#assign seq = ["winter", "spring", "summer", "autumn"]>
<#list seq as x>
${x_index + }. ${x}<#if x_has_next>,</#if>
</#list>
4 include指令
<#assign me = "Juila Smith">
<h1>Some test</h1>
<p>Yeah.
<hr>
<#include "/common/copyright.ftl">
5 compress指令
<#assign x = " moo \n\n ">
(<#compress> ${moo}
test only
I said, test only
</#compress>)
当你使用了对空白不敏感的格式(比如HTML或XML)时压缩指令对于移除多余的空白是很有用的。它捕捉在指令体(也就是在开始标签和结束标签中)中生成的内容,然后缩小所有不间断的空白序列到一个单独的空白字符。如果被替代的序列包含换行符或是一段空间,那么被插入的字符也会是一个换行符。开头和结尾的不间断的空白序列将会完全被移除。
上面输出结果为:
(
moo
test only
I said, test only)
freemarker常用标签解释的更多相关文章
- freemarker常用标签解释二
1 assign 指令 使用这个指令你可以创建一个新的变量,或者替换一个已经存在的变量.注意仅仅顶级变量可以被创建/替换(也就是说你不能创建/替换some_hash.subvar,除了some_has ...
- freemarker常用标签解释遍历
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...
- freemarker常用标签解释三
1 date,time,datetime 日期,时间,时间日期 <#assign test1 = "10/25/1995"?date("MM/dd/yyyy&quo ...
- Freemaker FTL指令常用标签及语法
https://blog.csdn.net/pengpengpeng85/article/details/52070602 FTL指令常用标签及语法 注意:使用freemaker,要求所有标签必须闭合 ...
- FTL指令常用标签及语法
FTL指令常用标签及语法注意:使用freemaker,要求所有标签必须闭合,否则会导致freemaker无法解析. freemaker注释:<#-- 注释内容 -->格式部分,不会输出 - ...
- OneBlog开源博客-详细介绍如何实现freemarker自定义标签
前言 OneBlog中使用到了springboot + freemarker的技术,同时项目里多个controller中都需要查询一个公有的数据集合,一般做法是直接在每个controller的方法中通 ...
- java常用英文解释
java常用名词解释: OO: object-oriented ,面向对象 OOP:object-oriented programming,面向对象编程 Author:JCC Object:对象JDK ...
- Struts2常用标签
Struts2常用标签总结 一 介绍 1.Struts2的作用 Struts2标签库提供了主题.模板支持,极大地简化了视图页面的编写,而且,struts2的主题.模板都提供了很好的扩展性.实现了更好的 ...
- Html常用标签元素
Html常用标签元素 Html常用标签元素 常用HTML标签元素结合及简介 <html></html> 创建一个HTML文档 <head></head> ...
随机推荐
- suse 源的添加与删除,以及源地址
地址 一个是上海交大的,http://ftp.sjtu.edu.cn/opensuse/update/ 葡萄牙的: http://ftp.nux.ipb.pt/pub/dists/opensuse/u ...
- js常见的字符串及数组处理
最近工作设计前台比较多,由于好久没动前台,或者使用前台框架习惯了,js有点生,将常见的字符串处理忘了,在这里整理一下常见的,以便于查阅: 1.substr():字符串分割,第一个是开始的下标,第二个是 ...
- android键盘的Done按钮
在EditText中,可以使用setImeOptions()方法来来开启软键盘的"Done"按钮. 示例代码如下:editText.setImeOptions(EditorInfo ...
- 使用Java2D改善API的绘制效果
---------------siwuxie095 工程名:TestSwingPaintAPI 包名:com.siwuxie095.swingp ...
- 列表控件JList的使用
--------------siwuxie095 工程名:TestUI 包名:com.siwuxie095.ui 类名:TestList.jav ...
- java web前端发送请求的4种方式
表单 action, 链接href,js 绑定按钮 ajax绑定标签 <h1>通过表单提交参数</h1> <form action="/day46_v1/Ser ...
- Tensorflow学习练习-卷积神经网络应用于手写数字数据集训练
# coding: utf-8 import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data mn ...
- varnish安装
安装pcrevarnish 依赖pcre进行url正则匹配. cd pcre-8.12./configure --prefix=/usr/local/make&&make instal ...
- oracle错误汇总解决
1.ORA-12514 http://blog.sina.com.cn/s/blog_5007d1b10100oqo8.html
- String、StringBuffer与StringBuilder之间区别 .RP
最近学习到StringBuffer,心中有好些疑问,搜索了一些关于String,StringBuffer,StringBuilder的东西,现在整理一下. 关于这三个类在字符串处理中的位置不言而喻,那 ...