SSH分页查询问题???

Java初学者,学习ssh框架的时候,遇到分页问题,控制台提示
空指针,DepartmentServiceImpl实现类中提示24行有错误,我觉得是当前页数
无法获取,求大神解决一下。
错误信息
图片说明

DepartmentServiceImpl实现类的代码为
package com.ssh.employee.service.impl;

import java.util.List;

import com.ssh.employee.dao.DepartmentDao;
import com.ssh.employee.entity.Department;
import com.ssh.employee.entity.PageBean;
import com.ssh.employee.service.DepartmentService;

public class DepartmentServiceImpl implements DepartmentService{

//注入Dao层的类
private DepartmentDao departmentDao;
public void setDepartmentDao(DepartmentDao departmentDao) {
    this.departmentDao = departmentDao;
}
@Override
public PageBean<Department> findByPage(Integer currPage) {
    // TODO Auto-generated method stub
    PageBean<Department> pageBean = new PageBean<Department>();
    //封装当前页数
    System.out.println("service 执行了");
    pageBean.setCurrPage(currPage);
    //封装每页显示记录数
    int pageSize= 3;
    pageBean.setPageSize(pageSize);
    //封装总记录数
    int totalCount = departmentDao.findCount();
    pageBean.setTotalCount(totalCount);
    System.out.println(pageBean.getTotalCount());//这个可以显示
    //封装总页数
    double tc = totalCount;
    Double num = Math.ceil(tc/pageSize);
    pageBean.setTotalPage(num.intValue());
    //封装每页显示的数据
    int begin = (currPage - 1) * pageSize;
    List<Department> list =  departmentDao.findByPage(begin,pageSize);
    System.out.println("service 执行了");
    pageBean.setList(list);
    return pageBean;
}

}


2个回答

空指针,打个断点看一下

空指针异常,要么参数为空,要么对象创建为空。打个断点看看,对象和参数上有值不

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问