岁月无痕. 2017-03-10 01:26 采纳率: 0%
浏览 980

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条回答 默认 最新

  • 谷大羽 2017-03-10 02:01
    关注

    空指针,打个断点看一下

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊