SSM+pagehelper分页

1.maven依赖


      com.github.jsqlparser
      jsqlparser
      3.0
    
    
    
      com.github.pagehelper
      pagehelper
      5.1.10
    

2.mybatis.xml( 关于pagehelper    https://pagehelper.github.io/docs/)


        
            
            
        
    

3.Controller

@Controller
public class StudentController {

    @Autowired
    private StuServiceImpl stuService;

    @ResponseBody
    @RequestMapping("/all")
    public PageInfo list(int currentPage, int pageSize) {
       return stuService.getAllStu(currentPage,pageSize);
    }
}

4.service和实现类

接口:

public interface StuService {
    public PageInfo getAllStu(int currentPage, int pageSize);
}

impl:

@Service
public class StuServiceImpl implements StuService {


    @Autowired
    private Stu_infoMapper stu_infoMapper;


    @Override
    public PageInfo getAllStu(int currentPage, int pageSize) {

        PageHelper.startPage(currentPage,pageSize);

        List stuInfoList =stu_infoMapper.AllStu();

        PageInfo pageInfo = new PageInfo(stuInfoList);

        return pageInfo;
    }
}

5.dao和mapper

public List AllStu();

  

 

6.网址输入

http://localhost:8080/all?currentPage=2&pageSize=3

你可能感兴趣的:(SSM+pagehelper分页)