Springmvc使用PageHelper分页插件
2021-04-23 18:28
标签:使用 session ISE factor gen override 容量 图片 color 1、导入相关依赖 2、在applicationContext.xml配置文件中增加PageHelper的定义 测试: 条件类: 编写一个接口: 编写一个接口的实现类: 测试数据: Springmvc使用PageHelper分页插件 标签:使用 session ISE factor gen override 容量 图片 color 原文地址:https://www.cnblogs.com/64Byte/p/13269452.html
dependency>
groupId>com.github.pagehelpergroupId>
artifactId>pagehelperartifactId>
version>5.0.0version>
dependency>
bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
property name="dataSource" ref="dataSource"/>
property name="configLocation" value="classpath:mybatis-config.xml"/>
property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"/>
property name="typeAliasesPackage" value="com.zl.newHouse.entity"/>
property name="globalConfig" ref="globalConfig"/>
property name="plugins">
array>
bean class="com.github.pagehelper.PageInterceptor">
property name="properties">
props>
prop key="helperDialect">oracleprop> //如果是mysql只需要更改为mysql即可
prop key="reasonable">trueprop>
props>
property>
bean>
array>
property>
bean>
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HouseQueryInfo {
private int pageIndex;//当前页码(页面传递)
private int pageSize;//页容量(后台设置)
private String title;
private String price_on;
private String price_down;
private String street_id;
private String type_id;
private String floorage_on;
private String floorage_down;
}
public interface IHouseService extends IService
//根据条件查询所有房屋信息,分页显示
@Override
public List
@Test
public void testpage() throws Exception{
HouseQueryInfo houseInfo = new HouseQueryInfo(1,3,"", "", "", "", "", "", "");
PageInfo pageInfo = houseService.findBookPage(houseInfo);
System.out.println("总数量" + pageInfo.getTotal());
System.out.println("当前页查询记录数" + pageInfo.getList().size());
System.out.println("当前页码" + pageInfo.getPageNum());
System.out.println("每页显示数量" + pageInfo.getPageSize());
System.out.println("总页" + pageInfo.getPages());
System.out.println("当前页查询记录" + pageInfo.getList());
}
下一篇:Java学习小记 3