1. 程式人生 > >在 jsp頁面中遍歷list中的資料

在 jsp頁面中遍歷list中的資料

   
    3)使用JSTL迴圈表示式方式(此方式不需要前提0,通過EL表示式
${itemCategoryList}可以直接取出request中的屬性值):  
        <select name="category" class="select1" id="category">
           <c:choose>
                <c:when test="${empty itemCategoryList}">
                    <tr>
                        <td colspan="3">沒有符合條件的資料</td>
                    </tr>
                </c:when>
                <c:otherwise>
                    <c:forEach items="${itemCategoryList}" var="itemCategoryList">
                        <tr>
                            <td>${itemCategoryList.name }</td>
                        </tr>
                    </c:forEach>
                </c:otherwise>

            </c:choose>        

        </select>