2

以下代码行是我正在处理的模板中的行的通用版本。我查看了 Velocity 模板语言文档,但无论我如何格式化此语句,我都会遇到错误。这是我对 VTL 的第一次真正体验,所以我希望能得到一组经验丰富的眼睛来解决这个问题:

#set($includeAttributes = 
   ${firstResponseItem.attribute1} != null || 
   ${firstResponseItem.attribute2 != null)
4

1 回答 1

2

Velocity中没有null,但您可以检查 null 值,就好像它是 boolean 一样false

#set($includeAttributes = $firstResponseItem.attribute1 || $firstResponseItem.attribute2)
于 2010-08-28T00:26:46.853 回答