Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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

Code Block
titleWrong
<saf<s:if test="#myObj.myStringaStringProperty == 'A'">
  Why doesn't this work when myString is equal to A?
</safs:if>

The solution is simple: flip the double and single quotes.

Code Block
titleRight
<saf<s:if test='#myObj.myStringaStringProperty == "A"'>
  This works!
</safs:if>

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

Code Block
titleAlso Right
saf<s:if test="#myObj.myStringaStringProperty == \"A\"">
  This works too!
</safs:if>