有一個需求,將所擁有的權限存放於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"></i> 綜合信息查詢<i class="Hui-iconfont menu_dropdown-arrow"></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>