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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: