码迷,mamicode.com
首页 > Web开发 > 详细

jstl 遍历数据

时间:2018-06-14 18:21:55      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:div   后端   requests   lib   class   对象   name   list   IV   

1   导入 jstl  的  jar 包

2. 页面中添加

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

3.   使用 jstl 遍历  employeeList  后端传过来的是一个 集合,   当动存放的是 对象

<c:if test="${empty requestScope.employeeList }">
        没有任何员工信息
    </c:if>
    <c:if test="${!empty requestScope.employeeList }">
        <table border="1" cellpadding="10" cellspacing="0">
            <tr>
                <th>ID</th>
                <th>LastName</th>
                <th>Email</th>
                <th>Gender</th>
                <th>Department</th>
                <th>Edit</th>
                <th>Delete</th>
            </tr>
            <c:forEach items="${requestScope.employeeList }" var="emp">
                <tr>
                    <td>${emp.id }</td>
                    <td>${emp.lastName }</td>
                    <td>${emp.email }</td>
                    <td>${emp.gender == 0 ? ‘Female‘ : ‘Male‘ }</td>
                    <td>${emp.department.departmentName }</td>
                    <td><a href="">Edit</a></td>
                    <td><a class="delete" href="emp/${emp.id }">Delete</a></td>
                </tr>
            </c:forEach>
        </table>
    </c:if>

 

jstl 遍历数据

标签:div   后端   requests   lib   class   对象   name   list   IV   

原文地址:https://www.cnblogs.com/redhat0019/p/9183426.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!