SSM项目pageHelper分页插件失效(采纳后酬谢!)

pom.xml导入的pagehelper

img


Service层的代码

package com.experience.service.impl;

import com.experience.dao.Book_all_dao;
import com.experience.entity.Book;
import com.experience.service.Book_all_service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Book_all_service_impl implements Book_all_service {
    @Autowired
    Book_all_dao book_all_dao;

    @Override
    public PageInfo<Book> getAllBooks() {
        PageHelper.startPage(2, 6);
        List<Book> book = book_all_dao.getBookList();
        PageInfo<Book> pageInfo = new PageInfo<>(book);
        System.out.println(pageInfo);
        return pageInfo;
    }
}


Controller层的代码

package com.experience.controller;

import com.experience.entity.Book;
import com.experience.service.Book_all_service;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class Book_all_Controller {
    @Autowired
    Book_all_service book_all_service;

@RequestMapping("/book")
    public void demo() {
    PageInfo<Book> info = book_all_service.getAllBooks();
    }

}


运行结果

img


我填入的是2和6,但是不管填多少,pageNum和pageSize总是默认的1页和我数据库内所有数据全部查出来,分了跟没分一样,分页插件不是可以实现数据库的片段吗?

去看看 应该怎能结局你的问题
https://blog.csdn.net/lst991120/article/details/107631594?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169184189216800192292073%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=169184189216800192292073&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-2-107631594-null-null.142^v92^chatgptT0_1&utm_term=SSM%E9%A1%B9%E7%9B%AEpageHelper%E5%88%86%E9%A1%B5%E6%8F%92%E4%BB%B6%E5%A4%B1%E6%95%88&spm=1018.2226.3001.4187