pagehelper

PageHelper 输出结果注释

感情迁移 提交于 2019-11-29 01:51:32
PageInfo{ pageNum=1,// 当前页码 pageSize=10,// 每页显示的跳数 size=10,// 该页的跳数 startRow=1,// 从第几条记录开始 endRow=10,// 到第几条结束 total=1536,// 总共多少条记录 pages=154,// 总页数 list=Page{ count=true, pageNum=1, pageSize=10, startRow=0, endRow=10, total=1536, pages=154, reasonable=false, pageSizeZero=false}[ com.zhiyou100.sh.bean.Users@515aebb0, com.zhiyou100.sh.bean.Users@dd8ba08, com.zhiyou100.sh.bean.Users@245b4bdc, com.zhiyou100.sh.bean.Users@6c64cb25, com.zhiyou100.sh.bean.Users@6ae5aa72, com.zhiyou100.sh.bean.Users@222545dc, com.zhiyou100.sh.bean.Users@5c5eefef, com.zhiyou100.sh.bean.Users@16293aa2, com.zhiyou100

Mybaiis(3)

随声附和 提交于 2019-11-29 01:44:13
本文大纲: 1.1动态sql语句 1.2逆向工程(generator) 1.3分页助手(pagehelper) 正文:    1.1动态sql语句       if语句:用于解决给定的值是空,而导致查询或执行其他操作的结果为空      where语句+if语句:用于解决当条件有多个,且此时第二个及以上条件满足而,第一个条件不满足时导致sql出错,"and" 或 ”or“ 无法正常使用时where语句将自动取舍"and" 或 ”or“         where语句+if语句:测试     set语句+if语句:用于修改时防止被修改的字段没有进行新的设置而导致将其字段在方法结束时变成null(可以理解为没有修改的字段保留原来的内容)      set语句+if语句测试: choos+when+otherwise+模糊查询:choos+when+otherwise类似于Java中的switch,而想使用模糊查询需要用到 函数concat() choos+when+otherwise+模糊查询测试: trim语句:可以当作where语句使用 trim语句测试: trim语句:可以当作set语句使用 trim语句测试: sql片段:用于将重复可用的sql语句单独取出,方便需要使用的时候引用 foreach 标签遍历:用于当多个条件的字段是同一个时,可以使用循环 foreach

Missing artifact com.github.pagehelper:pagehelper:jar:3.4.2-fix

元气小坏坏 提交于 2019-11-28 22:55:34
Maven中报错: Missing artifact com.github.pagehelper:pagehelper:jar:3.4.2-fix 错误原因是找不到pagehelper的jar,就是找不到和下载不了;其实你自己仔细一看报错信息3.4.2-fix。你看到过版本号后面有fix这种东西的吗?是自己打错了,或者拷贝的是出现了问题,或者是现如今取消了fix这个版本后缀,所以你回到parent工程红去掉-fix就可以了。 来源: CSDN 作者: 键盘源 链接: https://blog.csdn.net/qq_37909508/article/details/81735878

springboot集成mybatis

末鹿安然 提交于 2019-11-28 22:29:51
1、在pom文件中引入依赖 2、创建启动类 1 import org.mybatis.spring.annotation.MapperScan; 2 import org.springframework.boot.SpringApplication; 3 import org.springframework.boot.autoconfigure.SpringBootApplication; 4 5 /** 6 * Spring Boot启动类. 7 */ 8 @SpringBootApplication 9 @MapperScan("com.包名.*")//扫描:该包下相应的class,主要是MyBatis的持久化类.Mapper 10 public class App { 11 public static void main(String[] args) { 12 SpringApplication.run(App.class, args); 13 } 14 } 3、在application.properties添加配置文件 4、编写Demo实体类 5、编写DemoMapper接口 1 import java.util.List; 2 3 import org.apache.ibatis.annotations.Insert; 4 import org.apache.ibatis

TZ_09_MyBatis的pageHelper

淺唱寂寞╮ 提交于 2019-11-28 15:57:46
1..分页操作使用MyBatis的PageHelper 1>导入pageHelper的坐标 <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.1.2</version> </dependency> 2>在applicationContext.xml的 sqlSessionFactory 中配置Pagehelper <!--配置生产SqlSession对象的工厂 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!--扫描pojo包,给包下所有pojo对象起别名 --> <property name="typeAliasesPackage" value="com.hdh.domain" /> <!-- 传入PageHelper的插件 --> <property name="plugins"> <array> <!-- 传入插件的对象 --> <bean class="com.github.pagehelper

pagehelper分页插件的简单实用

时间秒杀一切 提交于 2019-11-28 12:54:00
结合mybatis实现对pagehelper分页插件的简单使用。 一、创建一个maven项目并导入相关依赖 依赖文件:pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mgy</groupId> <artifactId>Mybatis_10_pagehelper</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.4.1</version> </dependency> <dependency>

Mybatis3.4.x技术内幕(二十):PageHelper分页插件源码及原理剖析

做~自己de王妃 提交于 2019-11-28 12:21:00
PageHelper是一款好用的开源免费的Mybatis第三方物理分页插件,其实我并不想加上好用两个字,但是为了表扬插件作者开源免费的崇高精神,我毫不犹豫的加上了好用一词作为赞美。 原本以为分页插件,应该是很简单的,然而PageHelper比我想象的要复杂许多,它做的很强大,也很彻底,强大到使用者可能并不需要这么多功能,彻底到一参可以两用。但是,我认为,作为分页插件,完成物理分页任务是根本,其它的很多智能并不是必要的,保持它够傻够憨,专业术语叫stupid,简单就是美。 我们将简单介绍PageHelper的基本使用和配置参数的含义,重点分析PageHelper作为Mybatis分页插件的实现原理。 1. PageHelper的maven依赖及插件配置 <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.6</version> </dependency> PageHelper除了本身的jar包外,它还依赖了一个叫jsqlparser的jar包,使用时,我们不需要单独指定jsqlparser的maven依赖,maven的间接依赖会帮我们引入。 <!-- com.github.pagehelper为PageHelper类所在包名 -->

SSM-CRUD

元气小坏坏 提交于 2019-11-28 10:55:59
一、项目介绍 前端技术:query+Bootstrap+ajax+json 后端技术:SSM(spring、springMVC、mybatis)、JSR303校验 数据库:mysql 服务器:tomcat9.0 项目内容:对员工和部门进行增删改查操作、用pageHelper插件实现分页功能、全选/全不选等。 二、遇到的问题和解决方法 1、用pageHelper插件实现分页,pageSize=集合长度(pagehelper插件失效) pageInfo源码中: 1 if (list instanceof Collection) { 2 this.pageNum = 1; 3 this.pageSize = list.size(); 4 this.pages = this.pageSize > 0 ? 1 : 0; 5 this.size = list.size(); 6 this.startRow = 0; 7 this.endRow = list.size() > 0 ? list.size() - 1 : 0; 8 } 错误原因:pagehelper除了添加依赖,还需要在mybatis-config.xml中配置中添加拦截器PageInterceptor 1 <!-- https://mvnrepository.com/artifact/com.github.pagehelper

PageHelper踩坑

情到浓时终转凉″ 提交于 2019-11-28 08:27:27
刚开始死活分不了页,只显示默认的前 10条。搞了一下午,打了无数个断点都试不出毛病在哪。 下班又死磕到快8点,就在我已经绝望的时候,最后终于试出来了,把page.getTotal()给传到前端就好了。。。 public TableDataInfo project(@RequestParam(name = "pageSize", required = false)int pageSize, @RequestParam(name = "pageNum", required = false)int pageNum){ TableDataInfo table = new TableDataInfo(); Page<Enterprise> page = PageHelper.startPage(pageNum,pageSize); List<Enterprise> list = enterpriseService.selectEnterpriseList(enterprise); for(Enterprise data : list){ ProjectDto project = new ProjectDto(); project.setId(data.getId()); project.setName(data.getEnterpriseName()); project.setType

Mybatis分页方法

痞子三分冷 提交于 2019-11-27 21:06:26
使用方法 https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md 使用 Maven 在 pom.xml 中添加如下依赖: < dependency > < groupId >com.github.pagehelper</ groupId > < artifactId >pagehelper-spring-boot-starter</ artifactId > < version >1.2.5</ version > </ dependency > Example 可以这样调用,PageHelper. startPage (1,10)表示从第一页开始,每页10条记录,返回值为Page<>。 @RestController public class ProductController { @Autowired ProductMapper productMapper; @RequestMapping("getProduct") public Page<Product> getProduct(){ PageHelper.startPage(1,10); Page<Product> productList = (Page<Product>) productMapper