java从数据库中读取的数据怎样显示在jsp的网页当中

2024-11-09 20:29:13
推荐回答(1个)
回答1:

java从数据库中读取的数据显示在jsp的网页当中的方法是迭代table。
1、迭代数据的jsp页面代码:
















Name Email Address Phone No

2。后台java查询数据
public class RegisterAction extends ActionSupport{
String name,pwd,email,address;
int phno;

public RegisterAction() {}

List users = new ArrayList();
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";
}
}