Velocity 将 int i = 0 解释为 boolean false
Velocity is interpreting int i = 0 as boolean false
如果我检查 var int i = 0 是否存在,我会得到错误的结果:
#if($i)
<output>$i</output>
#end
结果:
i not defined --> no output
i = 0 --> no output
i = 1 --> <output>1</output>
我如何告诉 velocity 考虑定义的值 0?
i not defined --> no output
i = 0 --> <output>0</output>
i = 1 --> <output>1</output>
您可以通过 operator
查看
#if($i >= 0)
<output>$i</output>
#end
如果我检查 var int i = 0 是否存在,我会得到错误的结果:
#if($i)
<output>$i</output>
#end
结果:
i not defined --> no output
i = 0 --> no output
i = 1 --> <output>1</output>
我如何告诉 velocity 考虑定义的值 0?
i not defined --> no output
i = 0 --> <output>0</output>
i = 1 --> <output>1</output>
您可以通过 operator
查看#if($i >= 0)
<output>$i</output>
#end