2010-08-28 95 views
1

詞法正確的語句下面的代碼行是我工作的一個模板線的通用版本。我已經看過了Velocity模板語言Documentation,但我不斷收到錯誤,無論我如何格式化這個說法。這是我與VTL第一次真正的經驗,所以我希望得到一組經驗豐富的眼睛問題:什麼是Velocity模板語言

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

回答

2

中有速度沒有null,但你可以檢查空值,好像它是布爾false

#set($includeAttributes = $firstResponseItem.attribute1 || $firstResponseItem.attribute2)