select *
from (select rownum ro , d.*
from (select * from hdepartments order by department_name) d) de
where de.ro > 10 and de.ro <20
package com.action.common;
public class MyPageInof {
public static final int PAGENUME = 10;
private int allNum = 0;//总数
private int page = 0;//总页数
private int nowPage;//当前页数
private List date;//页面信息
}
package com.service;
MyPageInof mp = new MyPageInof();
mp.setAllNum(dd.getAllNum(con));
if(mp.getAllNum() % MyPageInof.PAGENUME == 0 ){
mp.setPage(mp.getAllNum() / MyPageInof.PAGENUME);
}else{
mp.setPage(mp.getAllNum() / MyPageInof.PAGENUME + 1) ;
}
mp.setDate(voList);
package com.dao;
public int getNum(Connection con) throws SQLException{
String sql = "select count(*) counNum from hdepartments";
PreparedStatement pred = con.prepareStatement(sql);
ResultSet rest = pred.executeQuery();
if(rest.next()){
return rest.getInt("counNum");
}
return 0;
}
show.jsp
<tr><td colspan="7" align="center">
第<select>
<%MyPageInof mp = (MyPageInof)request.getAttribute("mp");
for(int i= 0;i< mp.getPage() ;i++){ %>
<option><%=i %></option>
<%} %>
</select>页 总共<%=mp.getPage() %></td></tr>