<%@page import="com.sun.xml.internal.fastinfoset.util.PrefixArray"%> <%@ page language="java" import="java.util.*,com.zb.domain.*" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'goListEmp.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <table width="80%" border="1" align="center"> <tr><th>id</th><th>name</th><th>password</th><th>email</th><th>hiredate</th><th>salary</th><th>grade</th><th>department</th><th>删除用户</th></tr> <-- 方法一 for循环迭代--> <% List list=(List)request.getAttribute("empList"); for(int i=0;i<list.size();i++){ Employee e=(Employee)list.get(i); %> <tr> <th><%=e.getId() %></th> <th><%=e.getName() %></th> <th><%=e.getPassword() %></th> <th><%=e.getEmail() %></th> <th><%=e.getHiredate() %></th> <th><%=e.getSalary() %></th> <th><%=e.getGrade() %></th> <th><%=e.getDep() %></th> <th><a href="#">删除用户</a></th> </tr> <% } %> <!--方法2:S标签 --> <!-- <s:iterator value="#request.empList" id="e"> <tr> <th><s:property value="#e.id"/></th> <th><s:property value="#e.name"/></th> <th><s:property value="#e.password"/></th> <th><s:property value="#e.email"/></th> <th><s:property value="#e.hiredate"/></th> <th><s:property value="#e.salary"/></th> <th><s:property value="#e.grade"/></th> <th><s:property value="#e.dep.name"/></th> <th><a href="#">删除用户</a></th> </tr> </s:iterator> --> <!--方法3:c标签 --> <c:forEach items="${empList}" var="e"> <tr> <th>${e.id}</th> <th>${e.name}</th> <th>${e.password}</th> <th>${e.email}</th> <th>${e.hiredate}</th> <th>${e.salary}</th> <th>${e.grade}</th> <th>${e.dep.name}</th> <th><a href="#">删除用户</a></th> </tr> </c:forEach> </table> </body> </html>
jsp页面显示List中对象的属性三种方法
最新推荐文章于 2022-04-01 15:15:08 发布