在springboot项目中
使用之前需导包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
在在application.yml文件中配置分页自适应
pagehelper: //前面没有空格
reasonable: true //前面必须两个空格
auto-dialect: true
1,在pojo包中创建实体类 Plate
2, 在Mapper包中创建PlateMapper (包含 List selectByParamter(Plate plate);方法)
3, 在resoures资源文件夹下的Mapper文件加中创建PlateMapper.xml
<select id="selectByParamter" parameterType="plate" resultMap="BaseResultMap">
select ID, PNAME, PLEVEL, PID, SORT, IS_HOT, IS_LOGIN, URL
from T_PLATE
<where>
<if test="pname !=null and pname !=''">
-- and PNAME like '%'||#{pname,jdbcType=VARCHAR}||'%'
and PNAME like '%${pname}%'
</if>
<if test="plevel !=null and plevel !=0">
and PLEVEL = #{plevel,jdbcType=NUMERIC}
</if>
</where>
order by sort
</select>
4, 在Service包中创建PlateService (包含PageInfo page(Plate plate, int pageNumber, int pageSize);方法 )
5,在Service包中的impl包中创建PlateServiceImpl.java类,如下图
package com.seecen.sys.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.seecen.sys.mapper.IPlateMapper;
import com.seecen.sys.pojo.Plate;
i