日期:2014-05-17 浏览次数:20818 次
<body>
<center>
<h4>直接封装成对象list</h4>
<form action="regist">
<table align="center" width="360">
<tr>
<td>
第一个用户名:<input type="text" name="users[0].name" />
</td>
</tr>
<tr>
<td>
第一个密码:<input type="text" name="users[0].pass" />
</td>
</tr>
<tr align="center">
<td>
<input type="submit" value="转换">
<input type="reset" value="重填">
</td>
</tr>
</table>
</form>
</center>
</body>
public class RegistAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private List<User> users;
private String tip;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
public String execute() {
setTip("转换成功");
return SUCCESS;
}
}
<body>
<center>
<s:debug></s:debug>
<h3>类型转换后页面</h3>
key 为one的用户名为:<s:property value="users[0].name"/><br/>
key 为one的密码为:<s:property value="users[0].pass"/><br/>
</center>
</body>