检查 <s:iterator> 标签中 arraylist 中的 stat.count 值,用于 struts 2

use*_*590 5 jsp struts2

<% System.out.println("These indexed shall be shown on gui "+(ArrayList)request.getSession().getAttribute("selectedIndexes")); %>   // ArrayList value can be 2,3,5,9

  <s:iterator var="itr" value="#session.completeArrayList" status="stat">
 <s:if > //if stat.count value present in arraylist(selectedIndexes), then go to if loop
 </s:if

</s:iterator>
Run Code Online (Sandbox Code Playgroud)

我不知道如何在循环中检查%{#stat.count}值。我该怎么做arraylist{selectedIndexes}<s:if>

Akh*_*esh 5

您是否尝试过 index 和 count 属性。这是显示示例的链接

  <s:iterator status="status" value='%{0, 1}'>
      Index: <s:property value="%{#status.index}" /> <br />
      Count: <s:property value="%{#status.count}" /> <br />  
   </s:iterator>
Run Code Online (Sandbox Code Playgroud)

将打印

索引:0 计数:1 索引:1 计数:2


Ale*_*r M 4

Struts2使用OGNL并且它有in运算符。所以你可以像这样轻松地检查它:

<s:iterator var="itr" value="#session.completeArrayList" status="stat">
  <s:if test="#stat.count in #session.selectedIndexes">
  </s:if
</s:iterator>
Run Code Online (Sandbox Code Playgroud)