『J2EE』求助,如何将后台数据库中的数据在JSP页面显示?

2024-11-29 21:36:57
推荐回答(2个)
回答1:

很简单
比如结果集是rs
你可以直接rs.get(1)...之类的取里面的元素
也可以rs.get('数据库中字段')

回答2:

package util;

public class PageControl {

private int curpage; //当前页数
private int nextpage; //下一页
private int start; // 从第行页开始
private int end; //到第几行结束
private int totalpage; //总共页数
private int totalnum; //全部记录行数
private int prepage; //前一页

private int int_num=6; //每页显示记录行数
private int temp_curpage;
private int temp_start;
private int temp_end;
private int temp_totalnum;
private int temp_totalpage;

public void init(int curpage,int totalnum){
temp_totalnum=totalnum;
if(curpage>1){
if(curpage>(int)Math.ceil((double)totalnum/(double)int_num)){
temp_curpage=(int)Math.ceil((double)totalnum/(double)int_num);
}
else{
temp_curpage=curpage;
}
}
else{
temp_curpage=1;
}
temp_start = (temp_curpage - 1) * int_num+1;
temp_end = temp_curpage * int_num;
if (temp_end > temp_totalnum) {
temp_end=temp_totalnum;
}

temp_totalpage=(int)Math.ceil((double)totalnum/(double)int_num);

setCurpage();
setNextpage();
setStart();
setEnd();
setTotalpage();
setTotalnum();
setPrepage();

}

public void setCurpage() {
this.curpage = temp_curpage;
}

public void setNextpage() {
if(temp_curpage+1>temp_totalpage){
nextpage=curpage;
}
else{
nextpage=temp_curpage+1;
}
}

public void setStart() {
this.start = temp_start;
}

public void setEnd() {
this.end = temp_end;
}

public void setTotalpage() {
this.totalpage = temp_totalpage;
}

public void setTotalnum() {
this.totalnum = temp_totalnum;
}

public void setPrepage() {
if(temp_curpage-1<1){
prepage=temp_curpage;
}
else{
prepage=temp_curpage-1;
}
}

public int getCurpage() {
return curpage;
}
public int getNextpage() {
return nextpage;
}

public int getStart() {
return start;
}

public int getEnd() {
return end;
}

public int getTotalpage() {
return totalpage;
}

public int getTotalnum() {
return totalnum;
}

public int getPrepage() {
return prepage;
}

}