注册 登录
编程论坛 J2EE论坛

jsp页面实现查询并分页

zhangtao0563 发布于 2012-08-16 16:06, 649 次点击
新手不大会  再点击搜索图片之后应该写上面样的function  然后怎样实现查询并分页  求高手解决
//查询
function checkArc(aid){
   
}





<table border='0' cellpadding='0' cellspacing='0'>
        <tr>
        <td width='90' align='center'>搜索条件:</td>
          <td width='90' align='center'>广告位:</td>
          <td width='160'>        
              <input type="text" name= "adressname"  value='' style='width:150px'/>
          </td>
        <td width='70'>广告名称 </td>
        <td width='160'>
              <input type="text" name="adname" value='' style='width:150px' />
        </td>
        <!--  下面是一张搜索的图片   -->
        <td>
          <input name="imageField" type="image" src="images/frame/search.gif" onClick ="javascript:checkArc(0);" width="45" height="22" border="0" class="np" />
        </td>
       </tr>
      </table>
2 回复
#2
编程的乐趣2012-08-17 09:12
上谷歌百度查,有很多的分页写法
#3
北方凌云2012-11-03 11:35
public class Page {
        //总页数
        private int totalCountpage=1;
        //每页显示的记录数
        private int sizepage=0;
        //计算的总数
        private int recordcount=0;
        //当前页号
        private int currpageno=1;
        
        public int getCurrpageno() {
            if(totalCountpage==0)
                return 0;
            return currpageno;
        }
        public void setCurrpageno(int currpageno) {
            if(this.currpageno>0)
            this.currpageno = currpageno;
        }
        public int getTotalCountpage() {  //计算总页数时还得要把totalCountpage拿到
            return totalCountpage;
        }
        public void setTotalCountpage(int totalCountpage) {
            this.totalCountpage = totalCountpage;
        }
        public int getSizepage() {
            return sizepage;
        }
        public void setSizepage(int sizepage) {
            if(sizepage>0)
            this.sizepage = sizepage;
        }
        public int getRecordcount() {
            return recordcount;
        }
        public void setRecordcount(int recordcount) {
            if(recordcount>0){
            this.recordcount = recordcount;
            this.setSumpage();//计算总数的时候调用这个方法
        }   
    }

    // 设置总页数=总数量/每页显示的数据量+1
    private void setSumpage(){
        if(this.recordcount%this.sizepage==0)
            this.totalCountpage=this.recordcount/this.sizepage;
        else if(this.recordcount%this.sizepage>0)
            this.totalCountpage=this.recordcount/this.sizepage+1;
        else
            this.totalCountpage=0;
        }
     //得到开始记录数
    public int getStartrow(){
        return (currpageno-1)*sizepage+1;
    }
    //得到结束记录数
    public int getEndrow(){
        return currpageno*sizepage;
       }
}
1