注意写法
Why won't the 'if' tag evaluate a one cha
If care is not taken with the quoting of literals, the expression language (OGNL) will misinterpret a char as a String.
错误写法
if test="aStringProperty == 'A'"> Why doesn't this work when myString is equal to A? if>
The solution is simple: flip the double and single quotes.
正确写法
if test='aStringProperty == "A"'> This works! if>
Another solution is to escape the double quotes in the String.
正确写法
if test="aStringProperty == \"A\""> This works too! if>
Why won't the 'if' tag evaluate a one cha
If care is not taken with the quoting of literals, the expression language (OGNL) will misinterpret a char as a String.
错误写法
if test="aStringProperty == 'A'"> Why doesn't this work when myString is equal to A? if>
The solution is simple: flip the double and single quotes.
正确写法
if test='aStringProperty == "A"'> This works! if>
Another solution is to escape the double quotes in the String.
正确写法
if test="aStringProperty == \"A\""> This works too! if>
本文详细解释了在使用OGNL表达式时,若不正确引用字符串可能导致的误解,并提供了两种解决方法:翻转双引号和单引号,以及在字符串中转义双引号。
245

被折叠的 条评论
为什么被折叠?



