struts2 s:if tag constant comparision – strange behaviour

Consider this:

<s:if test=”memberBean.primaryAddress == ‘1’ “>checked</s:if>
You’d expect this line to print “checked” if memberBean.primaryAddress has a value “1” as that field is a string in the bean. But this evaluates to false and doesn’t print any thing. But if you change this to :
<s:if test=”memberBean.primaryAddress == 1 “>checked</s:if>
It will then print “checked”. The only difference was I remove the quotes next to 1. Wierd!!! Not like JSTL…so confusing.

Advertisements