struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Biesbrock, Kevin" <Biesbrock.Ke...@aoins.com>
Subject RE: [Struts2] String Comparison using s:if tag
Date Fri, 19 Dec 2008 21:22:50 GMT
Try:

user.sex.equals('M') 


Beez
( 4961 

-----Original Message-----
From: Raghu [mailto:techhelp07@gmail.com] 
Sent: Friday, December 19, 2008 4:20 PM
To: Struts Users Mailing List
Subject: [Struts2] String Comparison using s:if tag

Hi, I am trying to do String comparison in s:if tag as below but getting
number format exception....Looks like some problem with expression...

Any idea how to compare String values in s:if?

<s:if test="user.sex == 'M'">
Male
</s:if>
<s:elseif test="user.sex == 'F'">
Female
</s:elseif>



[WRITE4SMILE] WARN [2008/12/16 14:57:22] | Caught an exception while
evaluating expression 'user.sex == 'M'' against value stack
java.lang.NumberFormatException: For input string: "M"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Double.parseDouble(Unknown Source)
    at ognl.OgnlOps.doubleValue(OgnlOps.java:214)
    at ognl.OgnlOps.compareWithConversion(OgnlOps.java:99)
    at ognl.OgnlOps.isEqual(OgnlOps.java:142)
    at ognl.OgnlOps.equal(OgnlOps.java:533)
    at ognl.ASTEq.getValueBody(ASTEq.java:51)
    at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at ognl.SimpleNode.getValue(SimpleNode.java:210)
    at ognl.Ognl.getValue(Ognl.java:333)
    at com.opensymphony.xwork2.util.OgnlUtil.getValue(OgnlUtil.java:194)
    at
com.opensymphony.xwork2.util.OgnlValueStack.findValue(OgnlValueStack.jav
a:258)
    at
org.apache.struts2.components.Component.findValue(Component.java:322)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message