**
java springboot分页使用
**
1、pom文件添加依赖
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
<!-- 分页-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.2</version>
</dependency>
2、controller使用pageHelper
@GetMapping("attr/list")
public JSONResult attrList(String attribute_code,
String name,
@RequestParam(required = false) Integer type,
@RequestParam(required = false) Integer category,
@RequestParam(required = false,defaultValue = "10") Integer page,
@RequestParam(required = false,defaultValue = "1") Integer pageNum )
{
try
{
AttributesName attributesName = new AttributesName();
attributesName.setType(type);
attributesName.setName(name);
attributesName.setAttribute_code(attribute_code);
attributesName.setCategory(category);
PageHelper.startPage(pageNum,page);
List<AttributesRet> list = classificationService.getAttrList(attributesName);
return JSONResult.ok(list);
}
catch (Exception e)
{
return JSONResult.errorMsg(e.getMessage());
}
}