Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下代码行是我正在处理的模板中的行的通用版本。我查看了 Velocity 模板语言文档,但无论我如何格式化此语句,我都会遇到错误。这是我对 VTL 的第一次真正体验,所以我希望能得到一组经验丰富的眼睛来解决这个问题:
#set($includeAttributes = ${firstResponseItem.attribute1} != null || ${firstResponseItem.attribute2 != null)
Velocity中没有null,但您可以检查 null 值,就好像它是 boolean 一样false:
null
false
#set($includeAttributes = $firstResponseItem.attribute1 || $firstResponseItem.attribute2)