欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

struts2 标签 if 判断一个字符

程序员文章站 2022-06-20 10:41:45
...
注意写法
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>
相关标签: struts2 tag if