简体   繁体   中英

Contains Or Index of in <s:property> tag Struts2?

I have been looking for use <s:property> in struts2 if condtion...and I found the solution but Contains or IndexOf doesn't works in my case can someone help me on syntax....

<s:iterator value="DirList" status="DirSTS" var="Dir">
    <s:if test="#DetailsStatus.index==#DirSTS.index">
        <s:if test="%{#Dir.indexOf(':'}!= -1">
            <a href='<s:property/>'><small>Click Here </small></a>
        </s:if>                     
    </s:if>
</s:iterator>

Here DetailsStatus is main list status variable...here I want to check if <s:property> have : symbol

First thing that your syntax missing ) closing bracket. Second make sure you have correct values in list which have : Symbol(You have already commented that it have wrong values)

here is your code

<s:iterator value="DirList" status="DirSTS" var="Dir">
<s:if test="#DetailsStatus.index==#DirSTS.index">
    <s:if test="%{#Dir.indexOf(':'}!= -1">
        <a href='<s:property/>'><small>Click Here </small></a>
    </s:if>                     
</s:if>

change your code to like this ....

<s:iterator value="DirList" status="DirSTS" var="Dir">
<s:if test="#DetailsStatus.index==#DirSTS.index">
    <s:if test="#Dir.indexOf(':')!= -1">
        <a href='<s:property/>'><small>Click Here </small></a>
    </s:if>                     
</s:if>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM