Oracle java 分页

首先设置默认起始页

/** 页码 */
	private Integer pageNumber = 1;

 

// 计算当前页面
			int pageNumer = ccrInfoDao.getPageNumber();// 第几页
			int pageSize = ccrInfoDao.getPageSize();// 一页多少条
			int startRow = (pageNumer - 1) * pageSize;
			int endRow = startRow + pageSize;
			int pageNumber = total % pageSize == 0 ? total/pageSize : total/pageSize + 1;
			ccrInfoDao.setPageNumber(pageNumber);
			
			ccrInfoDao.setStartRow(startRow);
			ccrInfoDao.setEndStartRow(endRow);

sql:

select m.*
		from (select ROWNUM AS RN, t.*
		from (select distinct
		t1.company_id as companyId,
		t1.create_time as createTime,
		t1.company_name as companyName
		from ccrs_info t1
		where 1 = 1
		<if test="ccrAgentId != null and ccrAgentId !='' ">
			and t1.ccr_agentid =#{ccrAgentId}
		</if>
		and t1.is_vaild = 'Y'
		order by createTime desc) t) m
		where <![CDATA[ RN > #{startRow} and RN <=  #{endStartRow}]]>
		order by rn

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
package com.list.struts.util; import java.util.ArrayList; public class Page { //当前跳转的页面情况 private String pagetype; private PaginationBean pagination; private ArrayList result; //构造函数实例化接收一个pagetype和PaginationBean对象 public Page(String pagetype, PaginationBean pagination) { this.pagetype = pagetype; this.pagination = pagination; } /** * * */ public boolean isEmpty() { if (pagetype == null || pagetype.equals("")) { return true; } else { return false; } } /** * * * */ public ArrayList getResult() { if (!isEmpty()) { if (pagetype.equals("nextPage")) { result = pagination.getNextPage(); } else if (pagetype.equals("previousPage")) { result = pagination.getPreviouspage(); } else if (pagetype.equals("lastPage")){ result = pagination.getLastPage(); } else if (pagetype.equals("firstPage")){ result = pagination.getFirstPage(); } else{ result=pagination.getJumpPage(pagetype); } } else { result = pagination.getProducts(); } return result; } /** * * * */ //此对象中保存了页面的所有情况,包括多少页等信息 public PaginationBean getPagePagination() { return pagination; } /** * * */ //实例化PaginationBean的构造函数 public void Init(ArrayList result) { this.result = result; pagination = new PaginationBean(result); } } ------------------------------ import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.list.struts.form.ListForm; import com.list.struts.util.Page; import com.list.struts.util.PageBean; import com.list.struts.util.PaginationBean; import com.list.struts.vo.newgetResouce; public class ListAction extends Action { /* * Generated Method

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值