代码之家  ›  专栏  ›  技术社区  ›  Bobby

在速度模板语言中,词法上正确的陈述是什么

  •  1
  • Bobby  · 技术社区  · 15 年前

    下面这行代码是我正在处理的模板中某行的通用版本。我看过速度模板语言 Documentation 但不管我如何格式化这个语句,我都会不断出错。这是我在悉尼威立雅运输公司的第一次真正的经历,因此我希望在这个问题上获得一组经验丰富的眼睛:

    #set($includeAttributes = 
       ${firstResponseItem.attribute1} != null || 
       ${firstResponseItem.attribute2 != null)
    
    1 回复  |  直到 8 年前
        1
  •  2
  •   serg    15 年前

    没有 null 但您可以像布尔值一样检查空值。 false :

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