You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

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

Wrong
<saf:if test="#myObj.myString == 'A'">
Why doesn't this work when myString is equal to A?
</saf:if>

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

Right
<saf:if test='#myObj.myString == "A"'>
This works!
</saf:if>

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

Also Right
saf:if test="#myObj.myString == \"A\"">
This works too!
</saf:if>
  • No labels