:::: 개발 ::::/└ JSP & SPRING

JSTL 중복값 제거 .. 삽질

nayha 2017. 5. 13. 18:20

<c:set var="Ntest" value="d,d,d,d,d,d,g,g,g,g,g,g,e,e,e,e,e" />

<c:forEach items="${Ntest }" var="test"  varStatus="status">

<%-- 루프안에서 해당 값이 처음이면 저장 중복이면 저장안함 --%>

<c:if test="${status.current eq 'd' }">

<c:if test="${result1 ne '디지'}">

<c:set var="result1"  value="디지" />

</c:if>

</c:if>

<c:if test="${status.current eq 'g' }">

<c:if test="${result2 ne '골드'}">

<c:set var="result2"  value="골드" />

</c:if>

</c:if>

<c:if test="${status.current eq 'f' }">

<c:if test="${result3 ne '에프'}">

<c:set var="result3"  value="에프" />

</c:if>

</c:if>

<c:if test="${status.current eq 'e' }">

<c:if test="${result4 ne '이프'}">

<c:set var="result4"  value="이프" />

</c:if>

</c:if>  

 

</c:forEach>

<c:set var="result"  value= "${result1},${result2},${result3},${result4}" />


<c:forEach items="${result }" var="test2"  varStatus="status">

<c:choose>

<c:when test="${!status.last}">,${status.current}</c:when>

<c:otherwise>${status.current}</c:otherwise>

</c:choose>

</c:forEach>



반응형