岁月无痕. 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
    关注

    空指针,打个断点看一下

    评论

报告相同问题?

悬赏问题

  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题