How to evaluate struts 2 s: if?
I have an object called "item". it has a type property
when i do this:
<s:property value="item.type" />
I understand: Question
ok, so I can read the value, but when I try this:
<s:property value="item.type == 'Q'" />
I get an empty string
this gives me an empty string:
<s:property value="%{#item.type == 'Q'}" />
I even tried this:
<s:property value="item.type.equals('Q')" />
but i got this line: false
how can i get "true"?
ok, I struggled with this forever ... and in the end I learned how to do it. "Q" is a string literal compared to "Q", which is a character. so...
<s:if test="%{#item.type == 'Q'}">
will always be evaluated as false. try instead ...
<s:if test="%{#item.type == \"Q\"}">
I also saw how this is done ...
<s:if test='%{#item.type == ("Q")}'>
(note the single quotes around the value of the test attribute.)
OGNL - . , . , , - .