FreeMarker has_content等价于StringUtils.isNotNullOrEmpty
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的更多相关文章
- aes加解密前后端-后台
一.web.xml: <filter> <filter-name>fastLoginFilter</filter-name> <filter-class> ...
- springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息
1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...
- Java模板引擎Freemarker
Java模板引擎Freemarker 1.取值(插值)指令 2.逻辑指令:if.switch 3.字符串.集合操作 4.自定义函数 5.list排序内建函数.常用指令 6.自定义指令 7.freema ...
- FreeMarker中文API手册(完整)
FreeMarker概述 FreeMarker是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写 FreeMarker被设计用来生成HTML Web页面,特别是基于MVC模式的应用 ...
- Freemarker 各种格式化
1.格式化日期 ${updated?string("yyyy-MM-dd HH:mm:ss")} 如果指定的变量不一定存在,可以这样: ${(dateMap.beginTime?s ...
- StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】
isNotEmpty(str)等价于 str != null && str.length > 0 isNotBlank(str) 等价于 str != null &&am ...
- FreeMarker惯用内置函数
1.sequence?first 返回sequence的第一个值. 2.sequence?last 返回sequence的最后一个值. 3.sequence?reverse 将sequence的现有顺 ...
- FreeMarker中文API手冊(完整)
FreeMarker概述 FreeMarker是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯Java编写 FreeMarker被设计用来生成HTML Web页面,特别是基于MVC模式的应用 ...
- Freemarker详细解释
A概念 最经常使用的概念 1. scalars:存储单值 字符串:简单文本由单或双引號括起来. 数字:直接使用数值. 日期:通常从数据模型获得 布尔值:true或false,通常在<#if -& ...
随机推荐
- [MySQL学习]STRICT_ALL_TABLES相应的OUT of RANGE VALUE FOR COLUMN和DATA truncated FOR COLUMN
版权声明:声明:本文档能够转载,须署名原作者. 作者:无为 qq:490073687 周祥兴 zhou.xiangxing210@163.com https://blog.csdn.net/Rooki ...
- Spring中实现多数据源事务管理
文章转自 https://www.2cto.com/kf/201507/424229.html 前言 由于项目中引入了多个数据源,并且需要对多个数据源进行写操作,那么多数据源的事务管理自然成了不可避 ...
- Hibernate validator使用和自定义validator及整合Spring MVC
http://blog.csdn.net/lwphk/article/details/43983669 Hibernate validator使用 导入validation-api-xxx.jar 以 ...
- Python将数据渲染到docx文档指定位置
超简单Python将指定数据插入到docx模板渲染并生成 最近有一个需求,制作劳动合同表,要从excel表格中将每个人的数据导入到docx劳动合同中,重复量很大,因此可以使用python高效解决.为了 ...
- WebSocket原理与实践(四)--生成数据帧
WebSocket原理与实践(四)--生成数据帧 从服务器发往客户端的数据也是同样的数据帧,但是从服务器发送到客户端的数据帧不需要掩码的.我们自己需要去生成数据帧,解析数据帧的时候我们需要分片. 消息 ...
- Python脱产8期 Day01
一 编程语言与目的 1.有特定语法,可以通过编程的方式,让计算机进行识别,从而让计算机根据人的意愿完成人想让其完成的事 2.控制奴役计算机,让其完成你想让它完成的事,从而解放人力. 二 计算机 五大组 ...
- git速度太慢
适用各种操作系统,本次测试于ubuntu,下载速度从二十几k提高到二百多k 1.查找域名对应的ip地址,并修改hosts文件 nslookup github.global.ssl.fastly.Net ...
- 【Codeforces 1105E】Helping Hiasat
Codeforces 1105 E 题意:给你m个事件,每个事件可能是以下两种之一: \(1\),代表此时可以更改用户名 \(2\) \(s\),代表\(s\)来查看是否用户名与其名字相符 一共有\( ...
- linux笔记-多服务器同时执行相同命令
1.服务器的ip地址写到文件中,命名为nodelist.txt 192.168.1.160 192.168.1.166 2.编写运行脚本 for i in `cat nodelist.txt`do s ...
- Topographic ICA as a Model of Natural Image Statistics(作为自然图像统计模型的拓扑独立成分分析)
其实topographic independent component analysis 早在1999年由ICA的发明人等人就提出了,所以不算是个新技术,ICA是在1982年首先在一个神经生理学的背景 ...