freemarker基本知识总结

1、取出内容

${} 例如,${document.fileName}

2、

 <ul>
<#list cms.documents("channel=XXXX") as document>
<#switch document_index%3>
<#case 0>
<li style="357px;"><a href="#" title="${document.title}">${cms.substring(document.title, 20, "...")}</a></li>
 <#break>
<#case 1>
<li style="332px;"><a href="#" title="${document.title}">${cms.substring(document.title, 18, "...")}</a></li>
 <#break>
<#case 2>
<li style="281px;"><a href="#" title="${document.title}">${cms.substring(document.title, 15, "...")}</a></li>
 <#break>


</#switch>
</#list>
                  </ul>

以上代码包括<#list></#list>(这是循环遍历)<#switch></#switch>其中

 document_index是下标

3、
</#if>标签与else标签结合一起使用,控制逻辑
A、
<#if x = 1>
  x is 1
</#if> 
B、
<#if x = 1>
  x is 1
  <#else>
 x is not 1
</#if>
C、
<#if x = 1>
  x is 1
<#elseif x = 2>
  x is 2
<#elseif x = 3>
  x is 3
</#if>  
D、
<#if x = 1>
  x is 1
<#elseif x = 2>
  x is 2
<#elseif x = 3>
  x is 3
<#elseif x = 4>
  x is 4
<#else>
  x is not 1 nor 2 nor 3 nor 4
</#if> 

以上是if else 控制语句。


原文地址:https://www.cnblogs.com/woxiangxintj/p/4500780.html