在使用freemarker中的list时,需要做判空处理,这个和平时写java代码是一样的,做不判空在获取list 的内容时,会出现获取不到而报错,freemarker报错会比较难排查。ValidationException: null:3:6853: “fo:table-cell” is missing child elements
判空使用if
<#if xxPerson?exists && (xxPerson?size gt 0)>
list不为空
<#else>
list为空
</#if>
下面的连接中有几种判空的方法,在别的博客中看到不要使用大于号 “>” ,在freemarker中会被当做<#if 的结束位置。
http://www.51gjie.com/javaweb/1093.html
当list不为空时,获取list内容同样需要需要判空
和java代码编写是一样的,只是在freemarker中不熟悉