1、迭代数据的jsp页面代码:
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Address</th>
<th>Phone No</th>
</tr>
<s:iterator value="users">
<tr>
<td><s:property value="name"/></td>
<td><s:property value="email"/></td>
<td><s:property value="address"/></td>
<td><s:property value="phno"/></td>
</tr>
</s:iterator>
</table>
2。后台java查询数据
public class RegisterAction extends ActionSupport{
String name,pwd,email,address
int phno
public RegisterAction() {}
List<User>users = new ArrayList<User>()
UserDao udao = new UserDao()
//Getters and setters.
public String execute() throws Exception {
User u=new User()
u.setName(name)
u.setEmail(email)
u.setAddress(address)
u.setPhno(phno)
u.setPwd(pwd)
udao.addUser(u)
return "success"
}
public String listAllUsers(){
users = udao.getUsers()
System.out.println("In Action, "+users)
return "success"
}
}
方法如下:1、先在外面定义一个StringBuild
2、然后再循环里StringBuild.append(rs.getObject(1))
3、最后将字符串显示到JTextField里就行了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)