解决方案 »
- struts2中有个数组,获得每个数组的值然后执行某个action,怎么弄呢
- 关于网络通信--------------------
- 有哪位热心人士有jsp+ajax 树状菜单源码? 发到我QQ邮箱 286525467
- 请求一个jsp操作word的方法
- SOS------紧急求助,请高人指点一二(老板说,做不出来,你就走吧……可是,唉,跪拜求一程序)
- 一个servlet 导致HTTP 500错误
- applet 签名问题。请大侠过来看看
- 怎么样清除JB的历史配置问题。
- 点击按钮,弹出提示框,询问是否继续,我记得只需要在按钮哪行添加很简单的一句话,望大神指教
- web.xml里的监听器注释掉,项目就访问不了
- java web方面的面试一般会问什么问题
- struts2 request问题!
public int curPage; //当前是第几页
public int maxPage; //一共有多少页
public int maxRowCount; //一共有多少行
public int rowsPerPage = 8; //每页默认多少行
public java.util.List list;
public PageBean() {
}
//3
public void countMaxPage() { //根据总行数计算总页数
// //System.out.println("this.maxRowCount========"+this.maxRowCount);
if (this.maxRowCount % this.rowsPerPage == 0) {
this.maxPage = this.maxRowCount / this.rowsPerPage;
} else {
this.maxPage = this.maxRowCount / this.rowsPerPage + 1;
}
} public List getList() {
return this.list;
}
//1
public void setMaxRowCount(int maxRowCount){
this.maxRowCount=maxRowCount;
}
//2
public void setList(List list){
this.list=list;
}
//设置每页显示的行数
public void setRowsPerPage(int i){
this.rowsPerPage=i;
}
}
private int pageSize=15;//2.每页记录数
private int pageCount;//3.总页数
private int currentPage;//4.当前页数
private boolean next;//是否能下一页
private boolean previous;//是否能上一页
public PageBean( String currentPage , int rowCount ){
if( currentPage == null ){
//如果currentPage为空,则显示是首次访问
this.currentPage = 1;
}else{
this.currentPage = Integer.parseInt(currentPage);
}
this.rowCount = rowCount;
//计算总页数
this.pageCount = (int)Math.ceil(this.rowCount / (double)this.pageSize);
//计算是否能上一页和下一页
this.next = this.currentPage < this.pageCount;
this.previous = this.currentPage > 1;
}
* @description 根据PageBean分页查找部门对象
* @return 根据PageBean 查找部门对象的结果
* @param null
*/
public List<Dept> getDepts(PageBean pageBean) {
List<Dept> list = new ArrayList<Dept>();
String sql = "select top " +pageBean.getPageSize()+ " * from dept where dno not in " +
"( select top " +(pageBean.getCurrentPage()-1)*pageBean.getPageSize()+ " dno from dept order by dname) order by dname";
conn = db.getConnect();
try {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
Dept dept = new Dept();
dept.setDno(rs.getString("dno"));
dept.setDname(rs.getString("dname"));
list.add(dept);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
db.closeConnect(conn);
}
return list;
}