If care is not taken with the quoting of literals, the expression language (OGNL) will misinterpret a char as a String.
Code Block |
---|
|
<ww<s:if test="#myObj.myStringaStringProperty == 'A'">
Why doesn't this work when myString is equal to A?
</wws:if>
|
OGNL will interpret 'A' as a char type and not a string. Simple solution - The solution is simple: flip the double and single quotes.
Code Block |
---|
|
<ww<s:if test='#myObj.myStringaStringProperty == "A"'>
This works!
</wws:if>
|
Alternatively, you can Another solution is to escape the double quotes in the String:.
Code Block |
---|
|
<ww<s:if test="#myObj.myStringaStringProperty == \"A\"">
This works too!
</wws:if>
|