java - How to select distinct value from array items in jsp -
currently, want display value list items want remove duplicate value , showing unique value user.
i tried implement below code doesn't work .
<tr> <td class="col-ss1 col1">currency</td> <c:foreach items="${listproducts}" var="item" varstatus="loop"> <td class="col-ss1 "><c:foreach items="${item.terms}" var="term" varstatus="mainloop"> <c:if test="${(mainloop.index - 1) > 0}"> <c:foreach var="previousterm" items="${item.terms}" begin="0" end="${mainloop.index-1}" varstatus="inner"> <c:if test="${term.currencytype == previousterm.currencytype }"> <c:set var="flag" value="true"/> </c:if> </c:foreach> </c:if> <c:if test="${not flag}">${term.currencytype }</c:if> </c:foreach></td> </c:foreach> <!-- <td class="col-ss1 col2">vnĐ / usd / euro</td> <td class="col-ss1 col3">vnĐ / usd / euro</td> <td class="col-ss1 col4">vnĐ / usd / euro</td> <td class="col-ss1 col5">vnĐ / usd / euro</td> -->
it recommanded on server side, in java class...
list<string> yourlistcontainingdublicates... set<string> uniqueelementsset = new hashset<string>(yourlistcontainingdublicates)
the hashset constructor identifies duplicates invoking elements' equals() methods.
Comments
Post a Comment