50% Off/-

50% Off/-

Php

50% Off/-

50% Off/-

Web

50% Off/-

50% Off/-

How To Break Foreach Loop in JSP

10-06-2015

Jsp Page

In Jsp, there is no break element to break foreach loop, so we have used begin, end and var attributes. When parentPage is null, then count variable will be set to end attribute value to break foreach loop as follows:

<section class="in_sec_nrd">
    <article class="art_loop_nrd">
        Where I am:
        <c:forEach begin="0" end="100" var="count">
            <c:if test="${not empty parentPage}">
                <a title="${parentPage.title}" 
                    href="<c:url value="/content/${parentPage.url}" />">
                    ${parentPage.title}
                </a>
                >
                <c:set var="parentPage" value="${parentPage.parentPage}"/>
            </c:if>
            <c:if test="${empty parentPage}">
                <c:set var="count" value="100"/>
            </c:if>
        </c:forEach>

        <tiles:insertAttribute name="title"/>
    </article>
</section>

Css

.in_sec_nrd {
    width: 100%;
    float: left;
}

.art_loop_nrd {
    width: 100%;
    float: left;
    padding: 0 0 10px 0;
    color: #7b7b7b;
}

.art_loop_nrd a {
    color: #307d71;
}

.art_loop_nrd a:hover {
    text-decoration: underline;
    color: #e6352a;
}

.art_loop_nrd p {
    color: #2B2B2B !important;
}

© 2019 Tüm Hakları Saklıdır. Codesenior.COM