Reputation: 37
Hi i want to check the string in struts tag..
How to check whether the string1
conatins the string2
value?
for eg:
string1 = strutstag
string2 = tag
i want to do some logic if string1
contains string2
value
help me to do this... thanks in advance
Upvotes: 0
Views: 8170
Reputation: 18064
Try something like this:-
<s:if test="string1.indexOf(string2) != -1">
True
</s:if>
As per your update, variable representation in IF
condition is wrong.
It should be represented with #
symbol
<s:set name="string" value="%{'test'}" />
<s:set name="string1" value="%{'result'}" />
<s:if test="%{#counter.indexOf(#counter1) == -1}">
<font size="5" color="green">String Not Found.</font>
</s:if>
<s:else>
<font size="5" color="green">String Found.</font>
</s:else>
In your code, there is no counter
related variable.
Your condition should be
<s:if test="%{#string.indexOf(#string1) == -1}">
Upvotes: 3