struts2 if标签判断条件包含字符串的问题

阅读更多

http://struts.apache.org/2.x/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html

 

If care is not taken with the quoting of literals, the expression language (OGNL) will misinterpret a char as a String.

Wrong
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.

Right
if test='aStringProperty == "A"'>
  This works!
if>

Another solution is to escape the double quotes in the String.

Also Right
if test="aStringProperty == \"A\"">
  This works too!
if>

你可能感兴趣的:(struts2 if标签判断条件包含字符串的问题)