Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Rearranged to better list the several ways:</p> <ol> <li><p>With two <a href="http://struts.apache.org/release/2.3.x/docs/iterator.html" rel="nofollow"><code>Iterator</code></a>s:</p> <pre><code>&lt;s:iterator value="setOne" var="first" status="ctr1"&gt; &lt;s:iterator value="setTwo" var="second" status="ctr2"&gt; &lt;s:if test="%{#first == #second}"&gt; Common value detected : [&lt;s:property value="%{#first}"/&gt;] &lt;br/&gt; setOne position : [&lt;s:property value="%{#ctr1.index}"/&gt;] &lt;br/&gt; setTwo position : [&lt;s:property value="%{#ctr2.index}"/&gt;] &lt;br/&gt; &lt;/s:if&gt; &lt;/s:iterator&gt; &lt;/s:iterator&gt; </code></pre></li> <li><p>With a single Iterator and <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Set.html#contains%28java.lang.Object%29" rel="nofollow">Set.contains(Object)</a>:</p> <pre><code>&lt;s:iterator value="setOne" var="first" status="ctr1"&gt; &lt;s:if test="%{setTwo.contains('#first')}"&gt; Common value detected : [&lt;s:property value="%{#first}"/&gt;] &lt;br/&gt; &lt;/s:if&gt; &lt;/s:iterator&gt; </code></pre></li> <li><p>With a single Iterator and pure OGNL:</p> <pre><code>&lt;s:iterator value="setOne" var="first" status="ctr1"&gt; &lt;s:if test="%{#first in setTwo}"&gt; Common value detected : [&lt;s:property value="%{#first}"/&gt;] &lt;br/&gt; &lt;/s:if&gt; &lt;/s:iterator&gt; </code></pre></li> <li><p>Without Iterators, using <a href="http://commons.apache.org/proper/commons-ognl/language-guide.html" rel="nofollow">OGNL List Selection</a> only (thanks to @AleksandrM for the code):</p> <pre><code>&lt;s:property value="setOne.{? #this in setTwo}"/&gt; </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload