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 -& ...
随机推荐
- java list 排序,建议收藏的排序方法
每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code public static void main(String[] args) { ...
- 在阿里云Centos下LNMP环境搭建
首先,需要安装C语言的编译环境,因为Nginx是C语言编写的.通常大多数Linux都会默认安装GCC,如果没有的话,可以如下安装. 安装make: yum -y install gcc automak ...
- Git基础命令的使用——详细教程2
Git安装默认完成后,在左面点击鼠标右键,鼠标右键菜单中会多出来两个选项: a) Git GUI Here <—> 图型界面模式 b) Git Bash Here <—> ...
- metamask源码学习-controllers-network
https://github.com/MetaMask/metamask-extension/tree/master/app/scripts/controllers/network metamask- ...
- python 全栈开发,Day37(操作系统的发展史)
昨日内容回顾: # C/S和B/S架构 # osi五层模型 # 应用层 # 自定义协议(struct) _ 解决黏包 # 验证客户端合法性 _ hmac os.urandom # 解决TCP协议的se ...
- 工具 Sublime日志染色
工欲善其事,必先利其器. Preferences -> Browse Packages...
- java 面向对象基本知识
1.继承 使用extends实现继承 只有单继承 子类继承父类,可以得到父类的全部属性和方法 (除了父类的构造方法),但不见得可以直接访问(比如,父类私有的属性和方法). instanceof是二元 ...
- MySQL(九)插入、更新和删除
常用的SQL语句,除了select用于查询,还有insert.update.delete等. 一.insert insert:用来插入(或添加)行到数据库中,常见方式有以下几种: ①插入完整的行: ② ...
- mysql 修改字段
alter table dev_instant_video modify column content varchar(2500)alter table dev_instant_video_info ...
- PAM unable to dlopen(/lib/security/pam_limits.so): /lib/security/pam_limits.so: wrong ELF class: ELFCLASS32
systemctl status sshd● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/ ...