頁面編寫順序 首先肯定是否擁有想要的pojo(對象實體類)———》dao層mybatis配置——》service層的接口及實現類——》controller(web下)mysql
分頁插件做用於dao層,與之相關的是mybatis的配置git
<!-- 分頁插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency>
<configuration> <!-- 配置分頁插件 --> <plugins> <plugin interceptor="com.github.pagehelper.PageHelper"> <!-- 設置數據庫類型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六種數據庫--> <property name="dialect" value="mysql"/> </plugin> </plugins> </configuration>
而後在執行sql語句前加上github
//分頁處理web
PageHelper.startPage(1, 10); List<TbItem> list = mapper.selectByExample(example);//執行sql語句,返回列表
//分頁信息
PageInfo<TbItem> pageInfo=new PageInfo<>(list);
long total = pageInfo.getTotal();
System.out.println("共有商品:"+ total);sql