has_content

It is true if the variable exists (and isn't Java null) and is not "empty", otherwise it is false. The meaning of "empty" depends on the concrete case. This follows intuitive common-sense ideas. The following are empty: a string with 0 length, a markup output value with 0 length markup, a sequence or hash with no sub variables, a collection which has passed the last element. If the value is not of any of these types, then it counts as non-empty if it's a number or a date or a boolean (e.g. 0 and false are not empty), otherwise it counts as empty. Note that when your data-model implements multiple template model interfaces you may get unexpected results. However, when in doubt you can use always use expr!?size > 0 or expr!?length > 0 instead of expr?has_content.

This buit-in is exceptional in that you can use the parentheses trick like with the default value operator. That is, you can write bothproduct.color?has_content and (product.color)?has_content. The first doesn't handle the case when product is missing, the last does.

FreeMarker has_content等价于StringUtils.isNotNullOrEmpty的更多相关文章

  1. aes加解密前后端-后台

    一.web.xml: <filter> <filter-name>fastLoginFilter</filter-name> <filter-class> ...

  2. springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息

    1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...

  3. Java模板引擎Freemarker

    Java模板引擎Freemarker 1.取值(插值)指令 2.逻辑指令:if.switch 3.字符串.集合操作 4.自定义函数 5.list排序内建函数.常用指令 6.自定义指令 7.freema ...

  4. FreeMarker中文API手册(完整)

    FreeMarker概述 FreeMarker是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写 FreeMarker被设计用来生成HTML Web页面,特别是基于MVC模式的应用 ...

  5. Freemarker 各种格式化

    1.格式化日期 ${updated?string("yyyy-MM-dd HH:mm:ss")} 如果指定的变量不一定存在,可以这样: ${(dateMap.beginTime?s ...

  6. StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】

    isNotEmpty(str)等价于 str != null && str.length > 0 isNotBlank(str) 等价于 str != null &&am ...

  7. FreeMarker惯用内置函数

    1.sequence?first 返回sequence的第一个值. 2.sequence?last 返回sequence的最后一个值. 3.sequence?reverse 将sequence的现有顺 ...

  8. FreeMarker中文API手冊(完整)

    FreeMarker概述 FreeMarker是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写 FreeMarker被设计用来生成HTML Web页面,特别是基于MVC模式的应用 ...

  9. Freemarker详细解释

    A概念 最经常使用的概念 1. scalars:存储单值 字符串:简单文本由单或双引號括起来. 数字:直接使用数值. 日期:通常从数据模型获得 布尔值:true或false,通常在<#if -& ...

随机推荐

  1. 全排列(dfs)

    无重复元素的全排列 输入n(<=11),按从小到大输出数字1 到n 个的全部排列.样例:输入:3输出:1:1 2 32:1 3 23:2 1 34:2 3 15:3 1 26:3 2 1 全排列 ...

  2. Recurrences UVA - 10870 (斐波拉契的一般形式推广)

    题意:f(n) = a1f(n−1) + a2f(n−2) + a3f(n−3) + ... + adf(n−d), 计算这个f(n) 最重要的是推出矩阵. #include<cstdio> ...

  3. windows下手动安装 Apache+php+mysql

    PHP 为什么先说php,因为apache的配置要写入php的一些路径 http://php.net/downloads.php  选择windows donwload 选择Thread Safe的版 ...

  4. MetaMask/json-rpc-middleware-stream

    https://github.com/MetaMask/json-rpc-middleware-stream/blob/master/test/index.js#L20 A small toolset ...

  5. (转)解决k8s集群提示docker login问题(同样适用于Rancher)

    文章转自 https://blog.liv1020.com/ 参考文档:https://kubernetes.io/docs/concepts/containers/images/#configuri ...

  6. <数据结构与算法分析>读书笔记--模型

    为了在正式的构架中分析算法,我们需要一个计算模型.我们的模型基本上是一台标准的计算机,在机器中指令被顺序地执行.该模型有一个标准的简单指令系统,如加法.乘法.比较和赋值等.但不同于实际计算机情况的是, ...

  7. centos7安装python3和pip3

    python3安装 1.安装准备 # 创建安装目录 mkdir /usr/local/python3 #下载python3 wget --no-check-certificate https://ww ...

  8. linux中断源码分析 - 软中断(四)

    本文为原创,转载请注明:http://www.cnblogs.com/tolimit/ 在上一篇文章中,我们看到中断实际分为了两个部分,俗称就是一部分是硬中断,一部分是软中断.软中断是专门用于处理中断 ...

  9. [04] JSP标准动作

    1.概述 JSP规范中定义了一系列的标准动作,Web容器按照规范进行了实现,可以解析并执行标准动作.而标准动作使用的是标准的xml语法,看上去也比较直观易懂,下面来看一个结构例子: <jsp:a ...

  10. TCP/IP协议--TCP的超时和重传

    TCP是可靠传输.可靠之一体现在收到数据后,返回去一个确认.但是不能完全避免的是,数据和确认都可能丢失.解决这个办法就是,提供一个发送的重传定时器:如果定时器溢出时还没收到确认,它就重传这个报文段. ...