In my example the parameters are:
$p2.length
which has the value "0"
and the boolean
$suspectYesNo which is set to "false".
I would expect, that in my code the second #elseif will run due to my set parameters, but however it shows up that "Code 4 runs"
I guess, that my mistake is the connection of both conditions using "&&", but I have no clue how to correctly define the line with two conditions.
That brings me to the question: How to correctly combine the two conditions ($p2.length()==0) AND ($suspectYesNo.value.contains("true")) in one #elseif().
Or did I define the boolean wrong?
#if($p2.length()>0)
Code 1 runs
#elseif($p2.length()==0 && $suspectYesNo.value.contains("true"))
Code 2 runs
#elseif($p2.length()==0 && $suspectYesNo.value.contains("false"))
Code 3 runs
#else
Code 4 runs
#end
答案 0 :(得分:0)
感谢user7294900为我提供了解决问题的参考。
它没有将布尔值读取为字符串,可以通过添加“ toString()”方法来解决。
使用此代码可以按需工作:
#if($p2.length > 0)
Code 1 runs
#elseif($p2.length == 0 && $suspectYesNo.value.toString().contains("true"))
Code 2 runs
#elseif($p2.length == 0 && $suspectYesNo.value.toString().contains("false"))
Code 3 runs
#else
Code 4 runs
#end