---
title: "velocity判断null"
author: "JoeZe"
date: "2013-10-23T11:01:42Z"
tags: ["velocity"]
categories: ["企业架构"]
slug: "velocity-null"
draft: false
lastmod: "2013-10-23T11:15:15Z"
id: 1962610
url: "https://joeze.iteye.com/blog/1962610"
---

在使用velocity时出现了null时无效，在网上搜到这<http://wiki.apache.org/velocity/CheckingForNull>
使用了这个
#if ((! $car.fuel) && ("$!car.fuel" == ""))
可以解决问题，
在使用#set 时上面这个却会报错，只能使用
$null.isNull($foo)
$null这个需要new一个NullTool(),model.put("null",New NullTool()),但是velocity-tool却没有提供这个工具类，只能在复制<http://wiki.apache.org/velocity/NullTool>这个类到项目中使用，网上的资料都搞得好像自带的工具类一样，其实要自己导入==