标签:
显示效果
完整代码
1 <%@page import="java.util.*"%> 2 <%@ page language="java" pageEncoding="UTF-8"%> 3 <%@ taglib prefix="s" uri="/struts-tags" %> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 5 <html> 6 <head> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 <%! 11 class Person { 12 private String name; 13 private String sex; 14 public Person(){} 15 16 public void setName(String name){ 17 this.name = name; 18 } 19 public String getName(){ 20 return name; 21 } 22 public void setSex(String sex){ 23 this.sex = sex; 24 } 25 public String getSex(){ 26 return sex; 27 } 28 } 29 %> 30 <% 31 List list = new ArrayList(); 32 Person person = new Person(); 33 34 person.setName("小昆虫1"); 35 person.setSex("雄"); 36 list.add(person); 37 38 person.setName("小昆虫2"); 39 person.setSex("雌"); 40 list.add(person); 41 42 person.setName("小昆虫3"); 43 person.setSex("雌雄"); 44 list.add(person); 45 46 request.setAttribute("list", list); 47 %> 48 <table style="border: 1px solid red;"> 49 <s:iterator value="#request.list" id="li"> 50 <tr> 51 <td style="border: 1px solid red;"><s:property value="#li.name"/></td> 52 <td style="border: 1px solid red;"><s:property value="#li.sex"/></td> 53 </tr> 54 </s:iterator> 55 </table> 56 </body> 57 </html>
标签:
原文地址:http://www.cnblogs.com/xuqiulin/p/4461830.html