开发者

List in velocity macro, cannot find contains method

开发者 https://www.devze.com 2022-12-29 13:32 出处:网络
I put a list strings as validTypes in velocity. When I do : #if (${validTypes}.cont开发者_Go百科ains(\"aaa\"))

I put a list strings as validTypes in velocity. When I do :

#if (${validTypes}.cont开发者_Go百科ains("aaa"))
  // do something
#end

it throws an error. But when I do :

#foreach (${validType} in ${validTypes})
   ${validType}
#end

it works fine. Do I need to use velocity tools for this? How do I use it in an eclipse plugin? Are there any work around without using velocity tools?


The problem here is in curly brackets. Just use

#if (${validTypes.contains("aaa")})

or

#if ($validTypes.contains("aaa"))

instead.


For those who concern, this is how to write if not,

#if (!$validTypes.contains("aaa"))
0

精彩评论

暂无评论...
验证码 换一张
取 消