【问题标题】:What is the syntax for if false in nVelocity?nVelocity 中 if false 的语法是什么?
【发布时间】:2010-02-09 05:12:12
【问题描述】:

nVelocity(或 Velocity)中的非真或假 if 语句的语法是什么?

更重要的是,这在 nVelocity 文档中的什么位置?我已经在谷歌上搜索了很长一段时间都无济于事。

我尝试了几种不同的组合,例如:

#if (!$artist.IsFestival)

$artist.FestivalName

#end

#if ($artist.IsFestival == false)

$artist.FestivalName

#end

真令人沮丧!

提前致谢!

-EV

【问题讨论】:

标签: c# java asp.net velocity nvelocity


【解决方案1】:

这两个都应该有效,所以我认为您在访问“isFestival”时可能会遇到问题。您应该尝试使用 bean 语法 $artist.festival 或方法语法 $artist.isFestival()(您现在混合使用两者)。 该方法返回一个布尔值,对吧?

为了调试,试着打印出结果看看它是否有效:

 $artist            ## see if the artist is defined
 $artist.IsFestival  ## maybe an error   
 $artist.festival    ## should be true or false
 $artist.isFestival() ## should be true or false

更新:刚刚读到您在询问 nVelocity。我的回答可能只适用于 Java 版本。还是试试吧。

【讨论】:

  • 啊,非常感谢。但我真的需要知道如何否定测试,所以如果某事是not true。怎么说:if (NOT $artist.IsFestival)?
  • 您展示的两种模式都应该有效(!$x$x == false)。
  • 非常感谢 - 我会检查以确保属性设置为正确的值
猜你喜欢
  • 1970-01-01
  • 2014-11-05
  • 1970-01-01
  • 2020-04-24
  • 2011-01-24
  • 2020-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多