虽然FreeMarker提供了switch指令,但它并不推荐使用switch指令来控制也输出,而是推荐使用FreeMarker的if..elseif..else 指令来替代它。 3、list、break指令 list指令时一个典型的迭代输出指令,用于迭代输出数据模型中的集合。list指令的语法格式如下: <#list sequence as item> ... </#list> 除此之外,迭代集合对象...
mouse is cheaper than elephant <#else> elephant is cheaper than mouse </#if> 1. 2. 3. 4. 5. 加上elseif <#if animals.mouse.price < animals.elephant.price> mouse is cheaper than elephant <#elseif animals.elephant.price < animals.python.price> elephant is cheaper than mouse <#else> ...
Freemarker学习之if, else, elseif指令 if, else, elseif指令 基本形式 开始标签<#if >和结束标签</#if>成对出现,<#elseif>和<else>没有结束标签。 <#ifx==1>xis1<#elseif x==2>xis2<#elseif x==3>xis3<#elseif x==4>xis4<#else>xisnot1nor2nor3nor4</#if> 关于逻辑比较符号 当你想...
标签一: if else 你可以使用if,elseif和else指令来条件判断是否越过模板的一个部分。这些condition-s必须计算成布尔值,否则错误将会中止模板处理。elseif-s和else-s必须出现在if的内部(也就是,在if的开始标签和技术标签之间)。if中可以包含任意数量的elseif-s(包括0个)而且结束时else是可选的。 <#ifx == 1...
freemarkerifelseif FreeMarker模板 if, else, elseif 指令 :if, else, elseif 语法 <#if condition> ...<#elseif condition2> ...<#elseif condition3> ...<#else> ...</#if> ⽤例 <#if x = 1> x is 1 </#if> <#if x = 1> x is 1 <#else> x is not 1 </#if> ...
4.2、if、elseif、else 逻辑判断指令 4.3、List遍历指令 4.4、宏(macro)自定义指令 4.5、nested占位指令 4.6、import导入指令 4.7、include包含指令 五、FreeMarker中运算符的使用 5.1、算术运算符 5.2、逻辑运算符 5.3、比较运算符 5.4、空运算符 5.6、操作符的优先级 六、页面静态化 6.1、定义静态化模板 6.2、加...
else指令是一个典型的分支控制指令,作用完全类似于Java语言中的if。 示范代码: <#assignage= 23><#if(age>60)>老年人<#elseif (age>40)>中年人<#elseif (age>20)>青年人<#else>少年人</#if></#assign> 5. escape escape指令导致body区的插值都会被自动加上escape表达式,但不会影响字符串内的插值,...
freemarker中的if...elseif...else语句 1、设计示例 <#if student.studentAge lt 12> ${student.studentName}不是一个初中生 <#elseif student.studentAge lt 15> ${student.studentName}不是一个高中生 <#elseif student.studentAge lt 18>
6.2 if elseif else 逻辑判断指令 6.3 list遍历指令 6.4 marco 自定义指令 6.5 nested 占位指令 6.6 import 导入指令 6.7 include 包含指令 7 运算符 1 前提 2 freemarker 特性 3 FreeMarker环境搭建 1 创建maven环境 pom 文件里面配置 代码语言:javascript 复制 <?xml version="1.0" encoding="UTF-8"?> <pr...
if语句的基本语法如下: freemarker [#if 条件] ...(条件为真时显示的内容) [/#if] 此外,if语句还可以与elseif和else结合使用,以处理多个条件或提供默认内容: freemarker [#if 条件1] ...(条件1为真时显示的内容) [#elseif 条件2] ...(条件2为真时显示的内容) [#else] ...(以上条件都不为真时...