logic:迭代比较下一个值

时间:2013-07-23 20:31:03

标签: struts

我正在尝试将当前提交的内容进行比较。我有以下代码:

<logic:iterate id="anItem" name="dataPage" property="filingsList" 
    indexId="myInd">
    <bean:define id="currentSubmissionId" type="java.lang.String" 
    name="anItem" property="denseRank"/>

我想做点什么:

<logic:equal name="dataPage" property="currentSubmissionId"
 value="nextSubmissionId???">

    <img id="plus<%=rowCount%>" class="cursor" 
       src="<icis2:icisRes/>images/plus.gif" 
       onclick="toggle('<%=rowCount%>', this, 
       jQuery('#minus<%=rowCount%>'))"/>

    <img id="minus<%=rowCount%>" class="cursor" 
       src="<icis2:icisRes/>images/minus.gif" onclick="toggle('<%=rowCount%>', 
       this, jQuery('#plus<%=rowCount%>'))" style="display: none;"/>
</logic:equal>

谢谢,

汤姆

1 个答案:

答案 0 :(得分:0)

1. Create a temp string variable to "",
2. Store the current String here
3. Iterate, and compare. 
4. As you iterate check if equal or not. 
5. If equal print else copy next string to the variable.

这是代码。

    String[] someArrayOfStrings;  // Store the Strings here. You can use ArrayList too.
    String tempString = "";       // Recommend to use ArrayList.

    for(int count=0; count<someArrayOfStrings.length-1; count++){
       tempString = someArrayOfStrings[count];

       if(tempString.equalsIgnoreCase(someArrayOfStrings[count+1])){
            System.out.print(tempString);    
        }
    }

如果有帮助,请告诉我。