---
title: "velocity中的null与“”"
author: "xulongfa"
date: "2009-07-15T20:30:02Z"
tags: []
slug: "velocity-null"
draft: false
lastmod: "2009-07-15T20:30:02Z"
id: 426682
url: "https://xulongfa.iteye.com/blog/426682"
---

问题：vecolity中 #set($test=$map.getAtttibute("key"))  
         如果map.getAtttibute("key")为null,那么$test是null还是""  ?

结论：velocity引擎会报错：RHS of #set statement is null. Context will not be modified .

 

所以说最好是加上引号 ("")|感叹号 (!),  即#set($test=" $! map.getAtttibute("key")" )