zoukankan      html  css  js  c++  java
  • SSM框架使用分页插件显示信息

    1、在该SSM工程的pom.xml中加入PageHelper的分页插件依赖(若是版本号不对,可以尝试修改一下)

     1 <!-- 分页插件 -->
     2     <dependency>
     3         <groupId>com.github.miemiedev</groupId>
     4         <artifactId>mybatis-paginator</artifactId>
     5         <version>1.2.15</version>
     6     </dependency>
     7     <dependency>
     8         <groupId>com.github.pagehelper</groupId>
     9         <artifactId>pagehelper</artifactId>
    10         <version>3.4.2-fix</version>
    11     </dependency>

    2、在myBatis的配置文件中(SqlMapConfig.xml)加入分页插件的依赖:(下面这是SqlMapConfig.xml中的全部内容)

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <!DOCTYPE configuration
     3   PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
     4   "http://mybatis.org/dtd/mybatis-3-config.dtd">
     5 <configuration>
     6 
     7     <!-- 配置分页插件 -->
     8     <plugins>
     9         <plugin interceptor="com.github.pagehelper.PageHelper">
    10             <!-- 设置数据库类型 Oracle,Mysql,MariaDB(mysql分支),SQLite,Hsqldb,PostgreSQL六种数据库-->        
    11             <property name="dialect" value="mysql"/>
    12         </plugin>
    13     </plugins>
    14 </configuration>

    3、在spring整合文件(xml)中加入下面这句话:

    1 <!-- 加载mybatis的全局配置文件 -->
    2         <property name="configLocation" value="classpath:SqlMapConfig.xml" />

    别忘加对Maven工程进行Maven install!!!!!!

    4、ServiceImpl(此处我的EUDataGridResult是我返回给前台的一个实体类,把list集合封装起来了)

    EUDataGridResult:

    5、Controller

    6、我前台测试代码,界面比较丑,人家是用异步Ajax请求,我就简单模拟了一下:

    页面:

    7、结果如下:(我总共有十条数据,查询第三页,每页有四条数据)

  • 相关阅读:
    线性DP SGU167 I-country
    背包问题 POJ1742 Coins
    背包问题 codevs2210 数字组合
    dfs+贪心 BZOJ4027 [HEOI2015] 兔子与樱花
    spfa最短路+DP BZOJ1003 [ZJOI2006] 物流运输
    矩阵乘法 POJ3070 Fibonacci
    tarjan+spfa最短路 BZOJ1179 [Apio2009] Atm
    欧拉函数 BZOJ2190 [SDOI2008] 仪仗队
    矩阵乘法 洛谷 P3390【模板】矩阵快速幂
    裴蜀定理 BZOJ2299[HAOI2011] 向量
  • 原文地址:https://www.cnblogs.com/rgever/p/9455741.html
Copyright © 2011-2022 走看看