简体   繁体   English

计算Apache速度中的哈希图

[英]Evaluating an hashmap in apache velocity

I have a template like this 我有这样的模板

$VAR_A

$VAR_B

#foreach ($obj in $TEMPLATE_ANOTHER) 

Value of VAR_A is $VAR_A
Value of REFVAR_A is $obj.get("A")

#if($VAR_A == $obj.get("A"))
 print success
#else
 print failure
#end

#end

When merging the context, I provide values for VAR_A = a1, VAR_B = b1 and for TEMPLATE_ANOTHE, I provide a HashMap with the following entries 合并上下文时,我为VAR_A = a1,VAR_B = b1提供值,对于TEMPLATE_ANOTHE,我提供了具有以下条目的HashMap

("A", "a1")
("B", "b3")
("C", "c8")

On merging, the output expected is 合并后,预期输出为

Value of VAR_A is a1
Value of REFVAR_A is a1
print success

The == is simply not evaluating correctly and is printing failure. ==根本无法正确评估,并且打印失败。

Any suggestions? 有什么建议么?

i think "==" uses identity comparison, you probably need to use equals() instead to actually compare the objects, ie 我认为“ ==”使用身份比较,您可能需要使用equals()来实际比较对象,即

#if($VAR_A.equals($obj.get("A")))
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM