freemarker相关标签

<#if animals.python.price != 0>

Pythons are not free today!

</#if>

<#if animals.python.price < animals.elephant.price>

Pythons are cheaper than elephants today.

<#elseif animals.elephant.price < animals.python.price>

Elephants are cheaper than pythons today.

<#else>

Elephants and pythons cost the same today.

</#if>

上面示例中的一个问题是如果我们有0个水果,它仍然会输出一个空的 <ul></ul>,而不是什么都没有。 要避免这样的情况,可以这么来使用 list

<#list misc.fruits>

<ul>

      <#items as fruit>

<li>${fruit}

     </#items>

</ul>

</#list>

被 sep 覆盖的部分(我们也可以这么来写: ...<#sep>, </#sep></#list>) 只有当还有下一项时才会被执行。 因此最后一个水果后面不会有逗号:

<p>Fruits:

<#list misc.fruits as fruit>

${fruit}<#sep>,

</#list>

假设要在一些页面中显示版权声明的信息。那么可以创建一个文件来单独包含这些版权声明, 之后在需要它的地方插入即可,

当需要用到文件时,可以使用 include 指令来插入:

<#include "/copyright_footer.html">

时间: 2024-08-11 09:56:45

freemarker相关标签的相关文章

HTML5基础篇之列表相关标签和特殊字符实体

HTML字符实体 常用的字符实体: 实体字符 字符实体 大于号 (>) > 小于号 (<) < 引号 (") " 注册商标(®) ® 版权(© ) © & 号 & 空格符:&nbsp:这个空格在不同浏览器下空的距离也不同:还有一个空格符它的空格显示在各个浏览器都是一个字符的空格  一个&emsp:为空一个两个就两格依次类推. 列表的相关标签 无序列表:<ul> <li>新闻一</li> <

freemarker自定义标签报错(八)

1.错误描述 freemarker.core.ParseException: Token manager error: freemarker.core.TokenMgrError: Unknown directive: #assgin on line: 18, column: 151, in template: tag.ftl in tag.ftl at freemarker.template.Template.<init>(Template.java:174) at freemarker.c

freemarker自定义标签报错(三)

freemarker自定义标签 1.错误描述 freemarker.core.ParseException: Encountered " " at line 14, column 12 in myself.ftl. Was expecting one of: <STRING_LITERAL> ... <RAW_STRING> ... "false" ... "true" ... <INTEGER> ... &l

freemarker自定义标签

freemarker自定义标签 1.自定义标签说明 宏变量存储模板片段可以被用作自定义指令macro 2.示例说明 <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>freemarker自定义标签</title> </head> <body> <#--

freemarker自定义标签报错(四)

freemarker自定义标签 1.错误描述 六月 05, 2014 11:31:35 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template processing error: "Error executing macro: write\nrequired parameter: nums is not specified." Error executing macro: write required pa

1.2 文本相关标签

文本是网页不可缺少的元素之一,是网页发布信息所采用的主要形式.为了让网页中的文本看上去编排有序.整齐美观.错落有致,我们就要设置文本的大小.颜色.字体类型以及换行换段等. 本节单词记忆:标签 1.font 2.p 3.br 属性 1.color 2.size 3.face 4.align 网页学习网提示:html语言非常简单,不需要逻辑理解,而绝大部分朋友觉得它难以掌握,90%的原因在于英语单词不过关,所以每节记忆几个单词是非常有必要的. 一.字体字号相关标签 1.标题标签 标题能分隔大段文字,

freemarker自定义标签(二)

freemarker自定义标签 1.自定义标签 通过自定义标签,写一个重复指定字符串 2.实现源码 <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>freemarker自定义标签</title> </head> <body> <#--freemark

freemarker自定义标签(三)-nested指令

freemarker自定义标签 1.nested指令 是可选的,可以在<#macro>和</#macro>之间使用在任何位置和任意次数 2.示例说明 <#macro tag> <#nested/> </#macro> <@tag> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li>

freemarker自定义标签报错(七)

1.错误描述 六月 09, 2014 11:11:09 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template processing error: "Expression a is undefined on line 27, column 23 in tag.ftl." Expression a is undefined on line 27, column 23 in tag.ftl. The probl