zoukankan      html  css  js  c++  java
  • freemarker语法

    1.??

    <!-- ??是判断对象是否为空(??是?exists的缩写) -->
    <#if object ??>${object}<#if>
      如果object不为空,则执行里面语句

    2.? 
      用?判断是否为空,和??类似,但要在?后面加上关键字

    <!-- ?是"是否"的意思 -->
    <#if object?exists>${object}</#if>

      es:${nowDate?time} (将当前时间以时间的格式显示,如:11:11:11)
           ${nowDate?date} (将当前时间以日期的格式显示,如:2018-8-3)  
           注:time、date的格式可以在freemarker.properties文件中配置

    3.!
       ①${object!} 如果object为空则不执行
       ②取反

    <!--  如果为空则执行 -->
    <#if !object ??>${object}<#if>

    4.!!
       它的用法就是忽略list列表当中的空值
       es:
    <#list lists!! as list>
      这里如果lists当中有空值,没有!!的话,freemarker会直接抛出异常的

  • 相关阅读:
    struts2类型转换
    struts2拦截器
    计算机系统结构
    struts2标签
    struts2 OGNL表达式
    使用bootstrap
    Struts2-综合项目
    拦截器,课3
    struts2之OGNL
    Struts2框架
  • 原文地址:https://www.cnblogs.com/lingcheng7777/p/11641749.html
Copyright © 2011-2022 走看看