tags:

views:

379

answers:

2

Hi, Apologies If I am asking a very dumb question. I am trying one very simple thing.

<s:set name="tranType" value="%{'S'}" />
<s:if test="%{#tranType == 'S'}">
     blah
</s:if>

This doesn't work and I am getting following error. Please let me know If I should attach complete stack trace. If I use more than one character in for the value then it runs fine.

java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String at org.apache.struts2.components.Property.start(Property.java:136) at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:54) at org.apache.jsp.wrs.preview_005fwire_005fsplit_005famounts_jsp._jspx_meth_s_005fproperty_005f5(preview_005fwire_005fsplit_005famounts_jsp.java:348) at org.apache.jsp.wrs.preview_005fwire_005fsplit_005famounts_jsp._jspx_meth_s_005fiterator_005f1(preview_005fwire_005fsplit_005famounts_jsp.java:292)

A: 

Fixed this by doing following.

<s:set name="tranType" value='%{"S"}' />
<s:if test='%{#tranType == "S"}'>
     blah
</s:if>

Converted ' to " and vice-versa.

Nayn
A: 

I ran this with my version of struts -2.0.14 I believe - and it seems to execute as desired.

One thing I would like to ask is: are the %{} really necessary? It doesn't seem to change anything.

partkyle