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>