views:

302

answers:

2

I am trying to know why this code is not working when I compare a String with null in a JSP.

<s:set name="myvar" value="%{'teststring' != null}" /> <!-- always true -->
myvar value is ${myvar}

Above code works fine, and prints "myvar value is true".

But doing any of these

<s:property value="myvar" />
<s:property value="%{myvar}" />

throws a ClassCastException

Caused by: java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String

So I do not know how to solve it, as I need to disable some inputs based on that variable value, ie.

<s:select ... disabled="%{myvar}" />

Thank you very much for your help.

A: 

Try this

<s:property value="%{myvar.toString}" />
<s:select ... disabled="%{myvar.toString}" />
tevch
A: 

This seems to work: <s:property value="%{#myvar}" />

Jeff