用pagehelper插件分页

导入依赖

         <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.4.3</version>
        </dependency>

service层

package com.project.service;

import com.github.pagehelper.PageInfo;
import com.project.bean.userBean;

 public interface userService {  
 PageInfo<userBean> selectAll(int pageNO, int pageSize);
}

service实现类

package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.userBean;

import com.project.service.userService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class userServiceImpl implements userService {
    @Resource
    private com.project.dao.userDao userDao;



    @Override
    public PageInfo<userBean> selectAll(int pageNO, int pageSize) {
        PageHelper.startPage(pageNO,pageSize);
        PageInfo<userBean>pageInfo=PageInfo.of(userDao.selectAll());
        return pageInfo;
    }

   
}

dao层

package com.project.dao;

import com.project.bean.userBean;

import java.util.List;

public interface userDao {
   
    //分页显示所有用户信息
    List<userBean> selectAll();

  
}

 xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.project.dao.userDao">
<resultMap id="userMap" type="com.project.bean.userBean">
    <id column="user_id" property="userId"/>
    <result column="user_name" property="userName"/>
    <result column="user_pwd" property="userPwd"/>
    <result column="user_role" property="role"/>
    <result column="user_realName" property="realName"/>
</resultMap>

    
    <select id="selectAll" resultMap="userMap">
        select * from user_info
    </select>

   

</mapper>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值