zoukankan      html  css  js  c++  java
  • freemarker

    freemarker页面上的使用

    1,<#if condition> 和 </#if>   条件判断语句

    2,<#list sequence as loopVariable>repeatThis</#list>  list循环遍历语句

    <#list misc.fruits>

      <ul>

        <#items as fruit>

          <li>${fruit}

        </#items>

      </ul>

    </#list>

    在上面的遍历中,当一个fruit都没有的时候,<ul标签也不会存在。

    <#list misc.fruits>

      <p>Fruits:

        <ul>

          <#items as fruit>

            <li>${fruit}  <#sep> and</#sep>

           </#items>

        </ul>

    <#else>

          <p>We have no fruits.

    </#list>

    <#sep> 可以将遍历的结果用and字符串连接起来,而最后一个的后面不会有and

    <list> <#else> 可以联合起来使用

    3. 内建函数

    animal.name?cap_first 给出 animal.name 的首字母大写版本(比如 "Mouse" 来替代 "mouse")

    user?length 给出 user 值中 字符的数量(对于 "John Doe" 来说就是8)

    4. 处理不存在的变量

    <h1>Welcome ${user!"visitor"}!</h1>  如果user变量不存的情况下,就显示后面的visitor

    <#if user??><h1>Welcome ${user}!</h1></#if>  用判断语句,如果不存在,就会忽略整个问候语句

    参考中文在线手册:http://freemarker.foofun.cn/

  • 相关阅读:
    02-scrapy安装及目录结构
    drf结合sql server搭建后台管理系统
    drf连接sqlserver数据库
    drf xadmin
    drf goods设计
    drf user models设计
    什么是全文检索
    周进度总结
    程序员修炼之道阅读笔记(四)
    周进度总结
  • 原文地址:https://www.cnblogs.com/yanliang12138/p/10160745.html
Copyright © 2011-2022 走看看