【JSP JSTL】 多個判斷條件 + 滿足條件跳出循環


有一個需求,將所擁有的權限存放於session中,現在JSP頁面判斷這些如果在所有權限中有某一個或者某幾個,就顯示相對應的頁面內容

舉一個例子,實現以上的邏輯,<c:if>多個判斷條件 + <c:foreach>滿足條件跳出循環

<c:set var="flag" value="true" />
        <c:forEach items="${authoritys}" var="a">
            <c:if test="${(a.authorityName =='基因信息' || a.authorityName =='基因文獻' || a.authorityName =='基因文集')&& flag==true }">
            <c:set var="flag" value="false" />
                <dl id="menu-article">
                    <dt><i class="Hui-iconfont">&#xe616;</i> 綜合信息查詢<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
                    <dd>
                        <ul>
                            <c:forEach items="${authoritys}" var="a">
                                <c:if test="${a.authorityName =='基因信息' }">
                                    <li><a _href="../geneInfo/queryAll.htmls?queryType=product" href="javascript:void(0)">基因信息管理</a></li>
                                </c:if>
                            </c:forEach>
                            <c:forEach items="${authoritys}" var="a">
                                <c:if test="${a.authorityName =='基因文集' }">
                                    <li><a _href="../corlib/queryAll.htmls?queryType=corlib" href="javascript:void(0)">基因文集管理</a></li>
                                </c:if>
                            </c:forEach>    
                            <c:forEach items="${authoritys}" var="a">
                                <c:if test="${a.authorityName =='基因文獻' }">
                                    <li><a _href="../fileDeal/myFile.htmls" href="javascript:void(0)">基因文獻管理</a></li>
                                </c:if>
                            </c:forEach>
                        </ul>
                    </dd>
                </dl>
            </c:if>
        </c:forEach>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM