SoFunction
Updated on 2025-03-08

How SpringBoot integrates PageHelper paging function

Add MyBatis code and modify the following section:

1. Add MyBatisConfig

package ;

import ;

import ;
import ;

import ;

@Configuration
public class MyBatisConfig {
  @Bean
  public PageHelper pageHelper()
  {
    ("Use PageHelper");
    PageHelper pageHelper = new PageHelper();
    Properties p = new Properties();
    ("offsetAsPageNum", "true");
    ("rowBoundsWithCount", "true");
    ("reasonable", "true");
    (p);
    return pageHelper;
  }
}

2. Modify MyBatisController

package ;

import ;

import ;
import ;
import ;

import ;

import ;
import ;

@RestController
public class MyBatisController {
   @Autowired
   private MyBatisService myBatisService;
   
   @RequestMapping("likeName")
   public List<UserInfo> likeName(String username)
   {
     (1,2);
     return (username);
   }
}

3. Access address

http://localhost:8080/likeName?username=Tianheng

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.