Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页示例

Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页示例,第1张

概述本博客介绍基于SpringData这款orm框架加上Jquery.pagination插件实现的分页功能。本博客是基于一款正在开发中的github开源项目的,项目代码地址:https://github.com/u014427391/jeeplatform

本博客介绍基于Spring Data这款orm框架加上 Jquery.pagination插件实现的分页功能。

本博客是基于一款正在开发中的github开源项目的,项目代码地址:https://github.com/u014427391/jeeplatform

欢迎star(收藏)或者可以下载去学习,还在开发…

介绍一下Spring Data框架

spring Data : Spring 的一个子项目。用于简化数据库访问,支持Nosql 和 关系数据存储。

下面给出SpringData 项目所支持 Nosql 存储:

* MongoDB (文档数据库)
* Neo4j(图形数据库)
* Redis(键/值存储)
* Hbase(列族数据库)

SpringData 项目所支持的关系数据存储技术:

* JDBC
* JPA

JPA Spring Data : 致力于减少数据访问层 (DAO) 的开发量。开发者只要写好持久层接口就好,然后其它的框架会帮程序员实现。

开发步骤:

【Spring Data实现数据获取】

本项目是采用maven的,所以可以参考一下我的maven配置:

<project xmlns="@R_502_6822@://maven.apache.org/POM/4.0.0" xmlns:xsi="@R_502_6822@://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="@R_502_6822@://maven.apache.org/POM/4.0.0 @R_502_6822@://maven.apache.org/maven-v4_0_0.xsd">  <parent>    <artifactID>muses</artifactID>    <groupID>org.muses</groupID>    <version>1.0-SNAPSHOT</version>  </parent>  <modelVersion>4.0.0</modelVersion>  <artifactID>jeeplatform-admin</artifactID>  <packaging>war</packaging>  <name>jeeplatform-admin Maven Webapp</name>  <url>@R_502_6822@://maven.apache.org</url>  <propertIEs>    <spring.version>4.1.5.RELEASE</spring.version>    <spring-data-jpa.version>1.4.2.RELEASE</spring-data-jpa.version>    <spring-data-commons.version>1.6.2.RELEASE</spring-data-commons.version>    <hibernate.version>4.3.8.Final</hibernate.version>    <shiro.version>1.2.3</shiro.version>    <lucene.version>4.7.2</lucene.version>    <druID.version>1.0.9</druID.version>    <poi.version>3.7</poi.version>  </propertIEs>  <dependencIEs>    <!-- module start -->    <dependency>      <groupID>org.muses</groupID>      <artifactID>jeeplatform-core</artifactID>      <version>${jeeplatform.core.version}</version>    </dependency>    <dependency>      <groupID>org.muses</groupID>      <artifactID>jeeplatform-common</artifactID>      <version>1.0-SNAPSHOT</version>    </dependency>    <dependency>      <groupID>org.muses</groupID>      <artifactID>jeeplatform-oss</artifactID>      <version>${jeeplatform.oss.version}</version>    </dependency>    <dependency>      <groupID>org.muses</groupID>      <artifactID>jeeplatform-upms</artifactID>      <version>1.0-SNAPSHOT</version>    </dependency>    <!-- moudle end-->    <!-- servlet start-->    <dependency>      <groupID>javax.servlet</groupID>      <artifactID>servlet-API</artifactID>      <version>2.5</version>      <scope>provIDed</scope>    </dependency>    <!-- servlet end -->    <!-- Jstl start-->    <dependency>      <groupID>Jstl</groupID>      <artifactID>Jstl</artifactID>      <version>1.2</version>    </dependency>    <dependency>      <groupID>taglibs</groupID>      <artifactID>standard</artifactID>      <version>1.1.2</version>    </dependency>    <!-- Jstl end -->    <!-- log4j start-->    <dependency>      <groupID>log4j</groupID>      <artifactID>log4j</artifactID>      <version>${log4j.version}</version>    </dependency>    <!-- log4j end-->    <!-- Json解析需要的jar start-->    <dependency>      <groupID>commons-beanutils</groupID>      <artifactID>commons-beanutils</artifactID>      <version>1.8.3</version>    </dependency>    <dependency>      <groupID>commons-collections</groupID>      <artifactID>commons-collections</artifactID>      <version>3.2.1</version>    </dependency>    <dependency>      <groupID>net.sf.ezmorph</groupID>      <artifactID>ezmorph</artifactID>      <version>1.0.6</version>    </dependency>    <dependency>      <groupID>commons-lang</groupID>      <artifactID>commons-lang</artifactID>      <version>2.5</version>    </dependency>    <dependency>      <groupID>commons-logging</groupID>      <artifactID>commons-logging</artifactID>      <version>1.2</version>    </dependency>    <dependency>      <groupID>net.sf.Json-lib</groupID>      <artifactID>Json-lib</artifactID>      <version>2.4</version>      <type>jar</type>      <classifIEr>jdk15</classifIEr>      <scope>compile</scope>    </dependency>    <!-- Json解析需要的jar end -->    <!-- MysqL start-->    <dependency>      <groupID>MysqL</groupID>      <artifactID>mysql-connector-java</artifactID>      <version>${MysqL.version}</version>    </dependency>    <!-- MysqL end-->    <!-- commons -->    <dependency>      <groupID>commons-io</groupID>      <artifactID>commons-io</artifactID>      <version>2.0.1</version>    </dependency>    <dependency>      <groupID>commons-fileupload</groupID>      <artifactID>commons-fileupload</artifactID>      <version>1.2.2</version>    </dependency>    <!-- commons -->    <!-- spring framework start-->    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-core</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-beans</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-context</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-context-support</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-jdbc</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-tx</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-test</artifactID>      <version>${spring.version}</version>      <scope>test</scope>    </dependency>    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-web</artifactID>      <version>${spring.version}</version>    </dependency>    <!-- spring framework end -->    <!-- spring aop start-->    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-aop</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.aspectj</groupID>      <artifactID>aspectjweaver</artifactID>      <version>1.6.10</version>    </dependency>    <!-- spring aop end -->    <!-- springMVC start-->    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-webmvc</artifactID>      <version>${spring.version}</version>    </dependency>    <!-- springMVC end -->    <!-- spring data start-->    <dependency>      <groupID>org.springframework</groupID>      <artifactID>spring-orm</artifactID>      <version>${spring.version}</version>    </dependency>    <dependency>      <groupID>org.springframework.data</groupID>      <artifactID>spring-data-jpa</artifactID>      <version>${spring-data-jpa.version}</version>    </dependency>    <dependency>      <groupID>org.springframework.data</groupID>      <artifactID>spring-data-commons</artifactID>      <version>${spring-data-commons.version}</version>    </dependency>    <!-- spring data end -->    <!-- hibernate jpa start-->    <dependency>      <groupID>org.hibernate.javax.persistence</groupID>      <artifactID>hibernate-jpa-2.1-API</artifactID>      <version>1.0.0.Final</version>    </dependency>    <dependency>      <groupID>org.hibernate</groupID>      <artifactID>hibernate-core</artifactID>      <version>${hibernate.version}</version>    </dependency>    <dependency>      <groupID>org.hibernate</groupID>      <artifactID>hibernate-entitymanager</artifactID>      <version>${hibernate.version}</version>    </dependency>    <!-- hibernate jpa end -->    <!-- hibernate echache start-->    <dependency>      <groupID>org.slf4j</groupID>      <artifactID>slf4j-api</artifactID>      <version>1.6.1</version>    </dependency>    <dependency>      <groupID>net.sf.ehcache</groupID>      <artifactID>ehcache-core</artifactID>      <version>2.5.0</version>    </dependency>    <dependency>      <groupID>org.hibernate</groupID>      <artifactID>hibernate-ehcache</artifactID>      <version>${hibernate.version}</version>    </dependency>    <!-- hibernate echache end -->    <!-- 阿里的连接池druID start-->    <dependency>      <groupID>com.alibaba</groupID>      <artifactID>druID</artifactID>      <version>${druID.version}</version>    </dependency>    <!-- 阿里的连接池druID end-->    <!--shiro start-->    <dependency>      <groupID>org.apache.shiro</groupID>      <artifactID>shiro-all</artifactID>      <version>${shiro.version}</version>    </dependency>    <!-- shiro end-->    <!-- veLocity start-->    <dependency>      <groupID>org.apache.veLocity</groupID>      <artifactID>veLocity</artifactID>      <version>1.6</version>    </dependency>    <dependency>      <groupID>org.apache.veLocity</groupID>      <artifactID>veLocity-tools</artifactID>      <version>2.0</version>    </dependency>    <!-- veLocity end-->    <!-- lucene全文搜素引擎 start-->    <dependency>      <groupID>org.apache.lucene</groupID>      <artifactID>lucene-core</artifactID>      <version>${lucene.version}</version>    </dependency>    <dependency>      <groupID>org.apache.lucene</groupID>      <artifactID>lucene-analyzers-common</artifactID>      <version>${lucene.version}</version>    </dependency>    <dependency>      <groupID>org.apache.lucene</groupID>      <artifactID>lucene-queryparser</artifactID>      <version>${lucene.version}</version>    </dependency>    <dependency>      <groupID>org.apache.lucene</groupID>      <artifactID>lucene-memory</artifactID>      <version>${lucene.version}</version>    </dependency>    <dependency>      <groupID>org.apache.lucene</groupID>      <artifactID>lucene-Highlighter</artifactID>      <version>${lucene.version}</version>    </dependency>    <!-- 注意IKAnalyzer没有maven坐标,请自行添加到本地仓库 -->    <dependency>      <groupID>org.wltea.analyzer</groupID>      <artifactID>IKAnalyzer</artifactID>      <version>2012FF_u1</version>      <scope>system</scope>      <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/IKAnalyzer2012FF_u1.jar</systemPath>    </dependency>    <!-- lucene全文搜素引擎 end -->    <!-- log4j start-->    <dependency>      <groupID>log4j</groupID>      <artifactID>log4j</artifactID>      <version>${log4j.version}</version>    </dependency>    <!-- log4j end-->    <!-- Json解析需要的jar start-->    <dependency>      <groupID>commons-beanutils</groupID>      <artifactID>commons-beanutils</artifactID>      <version>1.8.3</version>    </dependency>    <dependency>      <groupID>commons-collections</groupID>      <artifactID>commons-collections</artifactID>      <version>3.2.1</version>    </dependency>    <dependency>      <groupID>net.sf.ezmorph</groupID>      <artifactID>ezmorph</artifactID>      <version>1.0.6</version>    </dependency>    <dependency>      <groupID>commons-lang</groupID>      <artifactID>commons-lang</artifactID>      <version>2.5</version>    </dependency>    <dependency>      <groupID>commons-logging</groupID>      <artifactID>commons-logging</artifactID>      <version>1.2</version>    </dependency>    <dependency>      <groupID>net.sf.Json-lib</groupID>      <artifactID>Json-lib</artifactID>      <version>2.4</version>      <type>jar</type>      <classifIEr>jdk15</classifIEr>      <scope>compile</scope>    </dependency>    <!-- Json解析需要的jar end -->    <!-- poi start-->    <dependency>      <groupID>org.apache.poi</groupID>      <artifactID>poi</artifactID>      <version>${poi.version}</version>    </dependency>    <!-- poi end-->    <!-- email start-->    <dependency>      <groupID>com.sun.mail</groupID>      <artifactID>javax.mail</artifactID>      <version>1.5.6</version>    </dependency>    <!-- email end-->  </dependencIEs>  <build>    <finalname>jeeplatform-admin</finalname>  </build></project>

设计好数据库,编写一个实体类:

package org.muses.jeeplatform.model.entity;import java.util.Date;import java.util.Set;import javax.persistence.CascadeType;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.FetchType;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.ID;import javax.persistence.JoinColumn;import javax.persistence.Jointable;import javax.persistence.ManyToMany;import javax.persistence.table;import javax.persistence.Temporal;import javax.persistence.TemporalType;/** * 用户信息的实体类 * @author Nicky */@Entity@table(name="sys_user")public class User {  /** 用户ID**/  private int ID;  /** 用户名**/  private String username;  /** 用户密码**/  private String password;  /** 手机号**/  private int phone;  /** 性别**/  private String sex;  /** 邮件**/  private String email;  /** 备注**/  private String mark;  /** 用户级别**/  private String rank;  /** 最后一次时间**/  private Date lastLogin;  /** 登录iP**/  private String loginIp;  /** 图片路径**/  private String imageUrl;  /** 注册时间**/  private Date regTime;  /** 账号是否被锁定**/  private Boolean locked = Boolean.FALSE;  private Set<Role> roles;      @GeneratedValue(strategy=GenerationType.IDENTITY)  @ID  public int getID() {    return ID;  }  public voID setID(int ID) {    this.ID = ID;  }  @Column(unique=true,length=100,nullable=false)  public String getUsername() {    return username;  }  public voID setUsername(String username) {    this.username = username;  }  @Column(length=100,nullable=false)  public String getpassword() {    return password;  }  public voID setPassword(String password) {    this.password = password;  }  public int getPhone() {    return phone;  }  public voID setPhone(int phone) {    this.phone = phone;  }  @Column(length=6)  public String getSex() {    return sex;  }  public voID setSex(String sex) {    this.sex = sex;  }  @Column(length=100)  public String getEmail() {    return email;  }  public voID setEmail(String email) {    this.email = email;  }  @Column(length=30)  public String getMark() {    return mark;  }  public voID setMark(String mark) {    this.mark = mark;  }  @Column(length=10)  public String getRank() {    return rank;  }  public voID setRank(String rank) {    this.rank = rank;  }  @Temporal(TemporalType.DATE)  public Date getLastLogin() {    return lastLogin;  }  public voID setLastLogin(Date lastLogin) {    this.lastLogin = lastLogin;  }  @Column(length=100)  public String getLoginIp() {    return loginIp;  }  public voID setLoginIp(String loginIp) {    this.loginIp = loginIp;  }  @Column(length=100)  public String getimageUrl() {    return imageUrl;  }  public voID setimageUrl(String imageUrl) {    this.imageUrl = imageUrl;  }  @Temporal(TemporalType.DATE)  @Column(nullable=false)  public Date getRegTime() {    return regTime;  }  public voID setRegTime(Date regTime) {    this.regTime = regTime;  }   public Boolean getLocked() {    return locked;  }  public voID setLocked(Boolean locked) {    this.locked = locked;  }}

编写接口实现Spring Data框架的PagingAndSortingRepository接口

package org.muses.jeeplatform.repository;import org.muses.jeeplatform.model.entity.User;import org.springframework.data.domain.Page;import org.springframework.data.domain.Pageable;import org.springframework.data.jpa.repository.JpaRepository;import org.springframework.data.jpa.repository.query;import org.springframework.data.repository.PagingAndSortingRepository;import org.springframework.data.repository.query.Param;import java.util.Date;public interface UserRepository extends PagingAndSortingRepository<User,Integer> {  /*User findByUsername(String username);  @query("from User u where u.username=:username and u.password=:password")  User findByUsernameAndPassword(@Param("username") String username,@Param("password") String password);  @query("from User u where u.ID=:ID")  User findByID(@Param("ID") int ID);  @query("from User u where date_format(u.lastLogin,'yyyy-MM-dd') between date_format((:startDate),'yyyy-MM-dd') and date_format((:endDate),'yyyy-MM-dd')")  Page<User> searchU(@Param("startDate")Date startDate,@Param("endDate")Date endDate,Pageable pageable);*/}

业务类实现:

package org.muses.jeeplatform.service;import java.util.*;import org.muses.jeeplatform.model.entity.User;import org.muses.jeeplatform.repository.UserRepository;import org.springframework.beans.factory.annotation.autowired;import org.springframework.data.domain.Page;import org.springframework.data.domain.PageRequest;import org.springframework.data.domain.sort;import org.springframework.data.jpa.domain.Specification;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import javax.persistence.criteria.CriteriaBuilder;import javax.persistence.criteria.Criteriaquery;/** * @description 用户信息管理的业务类 * @author Nicky  * @date 2017年3月6日 */@Servicepublic class UserService {  @autowired  UserRepository userRepository;  /**   * 构建PageRequest对象   * @param num   * @param size   * @param asc   * @param string   * @return   */  private PageRequest buildPageRequest(int num,int size,Sort.Direction asc,String string) {    return new PageRequest(num-1,size,null,string);  }  /**   * 获取所有的菜单信息并分页显示   * @param pageNo   *     当前页面数   * @param pageSize   *     每一页面的页数   * @return   */  @Transactional  public Page<User> findAll(int pageNo,int pageSize,Sort.Direction dir,String str){    PageRequest request = buildPageRequest(pageNo,pageSize,dir,str);    Page<User> users = userRepository.findAll(request);    return users;  }}

控制类,采用SpringMVC框架,先编写一个baseController,实现一些通用功能的封装:

package org.muses.jeeplatform.web.controller;import javax.servlet.@R_502_6822@.@R_502_6822@ServletRequest;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.web.context.request.RequestContextHolder;import org.springframework.web.context.request.ServletRequestAttributes;import org.springframework.web.servlet.ModelAndVIEw;public class BaseController {  Logger log = null;  /**   * 获取日志对象   * @return   */  public Logger getInstance(){    if(log == null){      log = LoggerFactory.getLogger(BaseController.class);    }    return log;  }  /**   * 得到request对象   */  public @R_502_6822@ServletRequest getRequest() {    @R_502_6822@ServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();    return request;  }  /**   * 得到ModelAndVIEw   */  public ModelAndVIEw getModelAndVIEw(){    return new ModelAndVIEw();  }}

控制类实现:

package org.muses.jeeplatform.web.controller;import net.sf.Json.JsONArray;import net.sf.Json.JsONObject;import net.sf.Json.JsonConfig;import org.apache.commons.collections.map.HashedMap;import org.muses.jeeplatform.core.Constants;import org.muses.jeeplatform.core.ExcelVIEwWrite;import org.muses.jeeplatform.core.JavaEmailSender;import org.muses.jeeplatform.model.entity.User;import org.muses.jeeplatform.service.UserService;import org.muses.jeeplatform.utils.DateJsonValueProcessor;import org.muses.jeeplatform.utils.DateUtils;import org.springframework.beans.factory.annotation.autowired;import org.springframework.data.domain.Page;import org.springframework.data.domain.sort;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapPing;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndVIEw;import javax.servlet.@R_502_6822@.@R_502_6822@ServletRequest;import javax.servlet.@R_502_6822@.@R_502_6822@ServletResponse;import java.io.PrintWriter;import java.util.*;/** * Created by Nicky on 2017/7/29. */@RequestMapPing("/user")@Controllerpublic class UserController extends BaseController{  @autowired  UserService userService;  /**   * 查询所有管理员信息并分页显示   * @param request   * @param response   * @param model   * @return   */  @RequestMapPing(value = "/queryAll",produces = "application/Json;charset=UTF-8")  @ResponseBody  public ModelAndVIEw findAll(@R_502_6822@ServletRequest request,@R_502_6822@ServletResponse response,Model model){    //当前页    String pageIndexStr = request.getParameter("pageIndex");    //每一页的页数    int pageSize = Constants.PAGE_SIZE;    ModelAndVIEw mv = this.getModelAndVIEw();    Page<User> userPage;    if(pageIndexStr==null||"".equals(pageIndexStr)){      pageIndexStr = "0";    }    int pageIndex = Integer.parseInt(pageIndexStr);    userPage = userService.findAll(pageIndex+1,Sort.Direction.ASC,"ID");    mv.addobject("totalCount",userPage.getTotalElements());    mv.addobject("pageIndex",pageIndex);//    JsonConfig cfg = new JsonConfig();//    cfg.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    JsonConfig jcg = new JsonConfig();    jcg.registerjsonValueProcessor(Date.class,new DateJsonValueProcessor("yyyy-mm-dd"));    JsONArray JsonArray = JsONArray.fromObject(userPage.getContent(),jcg);    //System.out.println(JsonArray.toString());    mv.addobject("users",JsonArray.toString());    mv.setVIEwname("admin/user/sys_user_List");    return mv;  }}

 【前端页面实现】

页面VIEw实现,引用 jquery.pagination.Js (分页Js),跟pagination.CSS(分页样式CSS)。

可以去这里下载:https://www.oudahe.com/p/45336/

<%@ page ContentType="text/HTML; charset=utf-8" pageEnCoding="utf-8"%><%@ taglib prefix="c" uri="@R_502_6822@://java.sun.com/Jsp/Jstl/core"%><%@ taglib prefix="fmt" uri="@R_502_6822@://java.sun.com/Jsp/Jstl/fmt"%><%  String path = request.getcontextpath();  String basePath = request.getScheme()+"://"+request.getServername()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML><HTML lang="zh-CN"><head>  <base href="<%=basePath %>" rel="external nofollow" >  <Meta charset="UTF-8" />  <Meta @R_502_6822@-equiv="X-UA-Compatible" content="IE=edge">  <Meta name="vIEwport" content="wIDth=device-wIDth,initial-scale=1">  <Title>Insert Title here</Title>  <!-- bootstrap样式-->  <link type="text/CSS" rel="stylesheet"     href="<%=basePath%>plugins/page/CSS/bootstrap-3.3.5.min.CSS" rel="external nofollow" />  <!-- jquery.pagination所需CSS -->  <link type="text/CSS" rel="stylesheet" href="<%=basePath%>plugins/page/CSS/pagination.CSS" rel="external nofollow" />  <script type="text/JavaScript" src="<%=basePath%>plugins/page/Js/jquery.min.Js"></script>  <!-- jquery.pagination所需Js 注意必须放在jquery.Js后面 -->  <script type="text/JavaScript" src="<%=basePath%>plugins/page/Js/jquery.pagination.Js"></script>  <script type="text/JavaScript">    /** 分页 *** 作,使用jquery.pagination插件 add by nicky 20170729 start **/    //当前页    var pageIndex = Number(${pageIndex});    //数据量    var totalCount = Number(${totalCount});    $(document).ready(function () {      //加入分页的绑定      $("#Pagination").pagination(totalCount,{        callback : pageselectCallback,prev_text : '< 上一页',next_text: '下一页 >',items_per_page : 6,num_display_entrIEs : 6,current_page : pageIndex,num_edge_entrIEs : 1,link_to: "user/queryAll?pageIndex=__ID__" //分页的Js中会自动把"__ID__"替换为当前的数。0      });      var HTML = "";      var data = ${users};      $.each(data,function(IDx,obj){        var ID = obj.ID;        var username = obj.username;        var mark = obj.mark;        var phone = obj.phone;        var email = obj.email;        var lastLogin = obj.lastLogin;        var loginIp = obj.loginIp;        HTML += "<tr><td><input type='checkBox' name='ID' ID='ID' value=" + ID + " /></td>" +          "<td>"+ID+"</td>"+          "<td>"+username+"</td>"+          "<td>"+mark+"</td>"+          "<td>"+phone+"</td>"+          "<td>"+email+"</td>"+          "<td>"+lastLogin+"</td>"+          "<td>"+loginIp+"</td>"+          "<td><a href='JavaScript:openEditDialog("+ID+");' class='bounceIn'>配置角色</a>"+          "</tr>";      });      $("#content").append(HTML);    });    //这个事件是在翻页时候用的    function pageselectCallback(index,jq) {    }    /** 分页 *** 作,使用jquery.pagination插件 add by nicky 20170729 end **/    //checkBox的全选/反选    var isCheckAll = false;    function doCheck(){      if(isCheckAll){        $("input[type='checkBox']").each(function(){          this.checked = false;        });        isCheckAll = false;      }else{        $("input[type='checkBox']").each(function(){          this.checked = true;        });        isCheckAll = true;      }    }  </script></head><body><br><div >  <div >    <div >      <div >        <div >          <form >            <input type="button"  value="发送邮件" onclick="sendEmail();" />            <input type="button"  value="发送短信" onclick="sendSms();" />            <input type="button"  value="导出Excel表" onclick="exportExcel();" />            <br><br><!--            <input type="text"  ID="keyword" placeholder="请输入关键词">                            日期从<input type="text"  placeholder="请输入开始日期" value="${startdate }" ID="startDate" name="startdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')}'});"/>            到<input type="text"  placeholder="请输入结束日期" value="${enddate }" ID="endDate" name="enddate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}'});" />                <input type="button"  value="Search" onclick="doSearch();"/>-->          </form>          <table  ID="mtable">            <thead>            <tr>              <th><input type="checkBox" onclick="doCheck();" /></th>              <th>序号</th>              <th>用户名</th>              <th>描述</th>              <th>手机</th>              <th>邮箱</th>              <th>最近登录</th>              <th>上次登录IP</th>              <th> *** 作</th>            </tr>            </thead>            <tbody ID="content">            </tbody>          </table>          <div ID="Pagination" ></div>          <!-- demo -->        </div>      </div>    </div>  </div></div></body></HTML>

前端页面展示:

ok,本博客是基于一款正在开发中的github开源项目的,项目代码地址:https://github.com/u014427391/jeeplatform

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。

总结

以上是内存溢出为你收集整理的Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页示例全部内容,希望文章能够帮你解决Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页示例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1224153.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存