首页 > 技术文章 > EL表达式遍历方法之一

bichen-01 2019-11-19 10:21 原文

 <table border="1px" cellpadding="0" cellspacing="0" width="200px">
        <tr class="red">
            <th>用户id:</th>
            <th>用户名:</th>
            <th>用户密码:</th>
        </tr>

        <c:forEach items="${UserList}" var="user">

            <c:if test="${user.userid%2==0}">
                <tr class="red">
                    <th>${user.userid}</th>
                    <th>${user.username}</th>
                    <th>${user.pwd}</th>
                </tr>
            </c:if>
            <c:if test="${user.userid%2!=0}">
                <tr class="blue">
                    <th>${user.userid}</th>
                    <th>${user.username}</th>
                    <th>${user.pwd}</th>
                </tr>
            </c:if>

        </c:forEach>
    </table>

 

推荐阅读