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、结果如下:(我总共有十条数据,查询第三页,每页有四条数据)

  • 相关阅读:
    start tag, end tag issues in IE7, particularly in xslt transformation
    用SandCastle为注释生成chm文档
    Firebug
    架构的重点
    Linux Shell常用技巧(十) 管道组合
    Linux JDK升级
    Linux Shell常用技巧(十二) Shell编程
    Packet Tracer 5.0实验(一) 交换机的基本配置与管理
    Linux Shell常用技巧(六) sort uniq tar split
    Linux Shell常用技巧(二) grep
  • 原文地址:https://www.cnblogs.com/rgever/p/9455741.html
Copyright © 2011-2022 走看看