日期:2014-05-17 浏览次数:20725 次
package com.s2.action; import java.util.List; import com.opensymphony.xwork2.ActionSupport; public class ListPropertyTestAction extends ActionSupport { private List<Person> people;//拿到 private List<String> tList;//拿不到 private String zhu;//拿到 public String getZhu() { return zhu; } public void setZhu(String zhu) { this.zhu = zhu; } public List<Person> getPeople() { return people; } public void setPeople(List<Person> people) { this.people = people; } public List<String> getTList() { return tList; } public void setTList(List<String> list) { tList = list; } @Override public String execute() { return SUCCESS; } }
package com.s2.action; public class Person { private String name; private String address; public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
<%@ page contentType="text/html; charset=UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <html> <head> <title>Hello World</title> </head> <body> <div style="color:red"> <s:fielderror /> </div> <s:form action="ListPropertyTestAction" theme="simple"> <table> <tr style="background-color:powderblue; font-weight:bold;"> <td> name </td> <td> address </td> </tr> <tr> <td> <input type="text" name="people[0].name" /> </td> <td> <input type="text" name="people[0].address" /> </td> </tr> <tr> <td> <input type="text" name="people[1].name" /> </td> <td> <input type="text" name="people[1].address" /> </td> </tr> <tr> <td> <input type="text" name="tList[0]" /> </td> <td> <input type="text" name="tList[1]" /> </td> </tr> <tr> <td> <input type="text" name="zhu" /> </td> <td> <s:submit /> </td> </tr> </table> </s:form> </body> </html>