Reputation: 71
I have problems comparing strings within an iterator JSP:
<s:iterator value="piecesTxt">
<s:if test="top.equals('_')">
<s:textfield name="solIntrod" theme="simple" size="2" maxlength="1"/>
</s:if>
<s:else>
<s:property/>
</s:else>
</s:iterator>
piecesTxt is a List that contains: - Pieces of text. - Gaps, storing in List the String "_"
JSP displays "_" as text:
El ot _ o d _ a f _ imos a na _ egar en un _ ate.
I've tried also with:
<s:if test="top == '_'">
Including in s:iterator var="pt"
<s:if test="pt == '_'">
<s:if test="pt.top == '_'">
<s:if test="pt.charAt(0) == '_'">
Other iterator-text works but this does not. Any ideas? Thanks in advance.
Upvotes: 0
Views: 224
Reputation: 160191
OGNL interprets a single character within single quotes as a char
, not a String
.
Use double-quotes:
<s:if test='top.equals("_")'>
See Why won't the 'if' tag evaluate a one char string for details.
Upvotes: 2