初学者。。不要鄙视哈``
请问怎么把这4个对象传到指定的result.jsp页面?
result.jsp里面又应该怎么写呢``
while (rs.next()) {
int theID = rs.getInt("ID");
String thetitle = rs.getString("title");
String thecontent = rs.getString("content");
String thetimes = rs.getString("times");
请问怎么把这4个对象传到指定的result.jsp页面?
result.jsp里面又应该怎么写呢``
while (rs.next()) {
int theID = rs.getInt("ID");
String thetitle = rs.getString("title");
String thecontent = rs.getString("content");
String thetimes = rs.getString("times");
你把它转换成List,在页面把list循环,如下:
List list = new ArrayList();
while (rs.next()) {
Tree tree = new Tree(); //这个是java bean对象
tree.setId(rs.getInt(1));
tree.setParentId(rs.getInt(2));
....
list.add(tree);
}
return list;这个只是给你提个代码片段
到jsp的话,你就把这个list循环出来就可以了!
页面循环已经写好了。
public Tree(){}
private int id;
private String title;
private String content;
private String times; public int getId() {
return id;
} public void setId(int id) {
this.id= id;
} public String getTitle() {
return title;
} public void setTitle(String title) {
this.title= title;
}
public String getContent() {
return content;
} public void setContent(String content) {
this.content= content;
} public String getTimes() {
return times;
} public void setTimes(String times) {
this.times= times;
}
}