- 浏览: 87664 次
- 性别:
- 来自: 重庆
文章分类
package 包名;
import java.util.Date;
public class Employee
{
private String id;
private String loginname;
private String name;
private String age;
private Date birthday;
private String dept_id;
private String position;
private String gender;
private String married;
private String salary;
private String educational;
private String country;
private String city;
private String remarks;
private String school;
private Date createtime;
private String email;
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getDept_id() {
return dept_id;
}
public void setDept_id(String dept_id) {
this.dept_id = dept_id;
}
public String getEducational() {
return educational;
}
public void setEducational(String educational) {
this.educational = educational;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getMarried() {
return married;
}
public void setMarried(String married) {
this.married = married;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getSalary() {
return salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
}
package 包名;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PageModel<T>
{
//结果集
private T model;
//查询记录数
private int totalRecords;
//每页多少条数据
private int pageSize=10;
//第几页
private int pageNo;
private int startIndex;
private int endIndex;
public int getEndIndex() {
return endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
/**
* 总页数
* @return
*/
public int getTotalPages() {
return (totalRecords + pageSize - 1) / pageSize;
}
/**
* 取得首页
* @return
*/
public int getTopPageNo() {
return 1;
}
/**
* 上一页
* @return
*/
public int getPreviousPageNo() {
if (pageNo <= 1) {
return 1;
}
return pageNo - 1;
}
/**
* 下一页
* @return
*/
public int getNextPageNo() {
if (pageNo >= getBottomPageNo()) {
return getBottomPageNo();
}
return pageNo + 1;
}
/**
* 取得尾页
* @return
*/
public int getBottomPageNo() {
return getTotalPages();
}
public int getTotalRecords() {
return totalRecords;
}
public void setTotalRecords(int totalRecords) {
this.totalRecords = totalRecords;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public T getModel() {
return model;
}
public void setModel(T model)
{
this.model = model;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="Employee">
<resultMap id="Employee.EmployeeResult" class="com.huasoft.common.domain.Employee" >
<result column="ID" property="id" jdbcType="VARCHAR" />
<result column="LOGINNAME" property="loginname" jdbcType="VARCHAR" />
<result column="NAME" property="name" jdbcType="VARCHAR" />
<result column="AGE" property="age" jdbcType="VARCHAR" />
<result column="BIRTHDAY" property="birthday" jdbcType="TIMESTAMP" />
<result column="DEPT_ID" property="dept_id" jdbcType="VARCHAR" />
<result column="POSITION" property="position" jdbcType="VARCHAR" />
<result column="GENDER" property="gender" jdbcType="VARCHAR" />
<result column="MARRIED" property="married" jdbcType="VARCHAR" />
<result column="SALARY" property="salary" jdbcType="VARCHAR" />
<result column="EDUCATIONAL" property="educational" jdbcType="VARCHAR" />
<result column="COUNTRY" property="country" jdbcType="VARCHAR" />
<result column="CITY" property="city" jdbcType="VARCHAR" />
<result column="REMARKS" property="remarks" jdbcType="VARCHAR" />
<result column="SCHOOL" property="school" jdbcType="VARCHAR" />
<result column="CREATETIME" property="createtime" jdbcType="TIMESTAMP" />
<result column="EMAIL" property="email" jdbcType="VARCHAR" />
</resultMap>
<select id="Employee.selectListByCondition"
parameterClass="java.util.HashMap"
resultMap="Employee.EmployeeResult">
select * from (select ROWNUM ROW_NUM,t.* from (
select id, loginname, age, birthday, dept_id, position, gender,
married, salary, educational, country, city, remarks, school, createtime, e mail,name from t_employee where +"条件根据自己项目实际需求") t) WHERE ROW_NUM BETWEEN #page.startIndex# AND #page.endIndex#
</select>
</sqlMap>
Java代码
package 包名;
import java.io.Serializable;
import java.util.List;
public interface BaseDao<T> {
/**
* sql查询列表
*
* @param statementId
* sql语句名称后缀
* @param parameters
* sql参数
* @return 查询结果
*/
List<T> queryForList(T model,String statementId, int startIndex,int endIndex);
}
Java代码
package 包名;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
public class BaseDaoImpl<T> extends SqlMapClientDaoSupport implements BaseDao<T>{
public <T> T queryForList(T model, String statementId,int startIndex,int endIndex) {
PageModel<T> page=new PageModel<T>();
page.setModel(model);
page.setStartIndex(startIndex);
page.setStartIndex(endIndex);
Map map=new HashMap();
map.put("page",page);
List<T> list=getSqlMapClientTemplate().queryForList("statementId",map);
return list;
}
}
Java代码
package 包名
import java.util.List
public class Test{
public static void main(String args[]){
BaseDao<Employee> base=new BaseDaoImpl<>();
Employee employee=new Employee ();
//从数据库中取出前10条记录
List list=base.queryForList(employee,"statementId",1,10);
//遍历list集合
}
}
Java代码
####################################
# Database Connectivity Properties
####################################
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@数据库IP地址:1521:SID
username=数据库用户名
password=数据库密码
Java代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="examples/domain/database.properties"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property value="${driver}" name="JDBC.Driver"/>
<property value="${url}" name="JDBC.ConnectionURL"/>
<property value="${username}" name="JDBC.Username"/>
<property value="${password}" name="JDBC.Password"/>
</dataSource>
</transactionManager>
<sqlMap resource="ibatis映射文件路径"/>
</sqlMapConfig>
http://shopsale.sinaapp.com
import java.util.Date;
public class Employee
{
private String id;
private String loginname;
private String name;
private String age;
private Date birthday;
private String dept_id;
private String position;
private String gender;
private String married;
private String salary;
private String educational;
private String country;
private String city;
private String remarks;
private String school;
private Date createtime;
private String email;
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getDept_id() {
return dept_id;
}
public void setDept_id(String dept_id) {
this.dept_id = dept_id;
}
public String getEducational() {
return educational;
}
public void setEducational(String educational) {
this.educational = educational;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getMarried() {
return married;
}
public void setMarried(String married) {
this.married = married;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getSalary() {
return salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
}
package 包名;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PageModel<T>
{
//结果集
private T model;
//查询记录数
private int totalRecords;
//每页多少条数据
private int pageSize=10;
//第几页
private int pageNo;
private int startIndex;
private int endIndex;
public int getEndIndex() {
return endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
/**
* 总页数
* @return
*/
public int getTotalPages() {
return (totalRecords + pageSize - 1) / pageSize;
}
/**
* 取得首页
* @return
*/
public int getTopPageNo() {
return 1;
}
/**
* 上一页
* @return
*/
public int getPreviousPageNo() {
if (pageNo <= 1) {
return 1;
}
return pageNo - 1;
}
/**
* 下一页
* @return
*/
public int getNextPageNo() {
if (pageNo >= getBottomPageNo()) {
return getBottomPageNo();
}
return pageNo + 1;
}
/**
* 取得尾页
* @return
*/
public int getBottomPageNo() {
return getTotalPages();
}
public int getTotalRecords() {
return totalRecords;
}
public void setTotalRecords(int totalRecords) {
this.totalRecords = totalRecords;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public T getModel() {
return model;
}
public void setModel(T model)
{
this.model = model;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="Employee">
<resultMap id="Employee.EmployeeResult" class="com.huasoft.common.domain.Employee" >
<result column="ID" property="id" jdbcType="VARCHAR" />
<result column="LOGINNAME" property="loginname" jdbcType="VARCHAR" />
<result column="NAME" property="name" jdbcType="VARCHAR" />
<result column="AGE" property="age" jdbcType="VARCHAR" />
<result column="BIRTHDAY" property="birthday" jdbcType="TIMESTAMP" />
<result column="DEPT_ID" property="dept_id" jdbcType="VARCHAR" />
<result column="POSITION" property="position" jdbcType="VARCHAR" />
<result column="GENDER" property="gender" jdbcType="VARCHAR" />
<result column="MARRIED" property="married" jdbcType="VARCHAR" />
<result column="SALARY" property="salary" jdbcType="VARCHAR" />
<result column="EDUCATIONAL" property="educational" jdbcType="VARCHAR" />
<result column="COUNTRY" property="country" jdbcType="VARCHAR" />
<result column="CITY" property="city" jdbcType="VARCHAR" />
<result column="REMARKS" property="remarks" jdbcType="VARCHAR" />
<result column="SCHOOL" property="school" jdbcType="VARCHAR" />
<result column="CREATETIME" property="createtime" jdbcType="TIMESTAMP" />
<result column="EMAIL" property="email" jdbcType="VARCHAR" />
</resultMap>
<select id="Employee.selectListByCondition"
parameterClass="java.util.HashMap"
resultMap="Employee.EmployeeResult">
select * from (select ROWNUM ROW_NUM,t.* from (
select id, loginname, age, birthday, dept_id, position, gender,
married, salary, educational, country, city, remarks, school, createtime, e mail,name from t_employee where +"条件根据自己项目实际需求") t) WHERE ROW_NUM BETWEEN #page.startIndex# AND #page.endIndex#
</select>
</sqlMap>
Java代码
package 包名;
import java.io.Serializable;
import java.util.List;
public interface BaseDao<T> {
/**
* sql查询列表
*
* @param statementId
* sql语句名称后缀
* @param parameters
* sql参数
* @return 查询结果
*/
List<T> queryForList(T model,String statementId, int startIndex,int endIndex);
}
Java代码
package 包名;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
public class BaseDaoImpl<T> extends SqlMapClientDaoSupport implements BaseDao<T>{
public <T> T queryForList(T model, String statementId,int startIndex,int endIndex) {
PageModel<T> page=new PageModel<T>();
page.setModel(model);
page.setStartIndex(startIndex);
page.setStartIndex(endIndex);
Map map=new HashMap();
map.put("page",page);
List<T> list=getSqlMapClientTemplate().queryForList("statementId",map);
return list;
}
}
Java代码
package 包名
import java.util.List
public class Test{
public static void main(String args[]){
BaseDao<Employee> base=new BaseDaoImpl<>();
Employee employee=new Employee ();
//从数据库中取出前10条记录
List list=base.queryForList(employee,"statementId",1,10);
//遍历list集合
}
}
Java代码
####################################
# Database Connectivity Properties
####################################
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@数据库IP地址:1521:SID
username=数据库用户名
password=数据库密码
Java代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="examples/domain/database.properties"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property value="${driver}" name="JDBC.Driver"/>
<property value="${url}" name="JDBC.ConnectionURL"/>
<property value="${username}" name="JDBC.Username"/>
<property value="${password}" name="JDBC.Password"/>
</dataSource>
</transactionManager>
<sqlMap resource="ibatis映射文件路径"/>
</sqlMapConfig>
http://shopsale.sinaapp.com
相关推荐
本压缩包“超强php分页打包 通用分页 万能分页 ajax分页 google分页”提供了一系列的分页解决方案,包括了基本的PHP分页、通用的分页实现、以及结合AJAX技术的动态分页,旨在满足各种项目需求。下面将详细介绍这些...
本教程将深入讲解如何利用RecyclerView实现横向和纵向的分页滑动,充分利用Android原生功能。 首先,理解RecyclerView的基本结构。RecyclerView包含一个Adapter,它负责将数据集绑定到视图上,以及一个...
在网页开发中,分页是一种常见的用户界面设计,用于处理大量数据时的高效展示。Java AJAX(Asynchronous JavaScript and XML)分页与JSP(JavaServer Pages)相结合,可以提供无需刷新整个页面即可动态加载更多内容...
在网页开发中,分页是不可或缺的一个功能,特别是在数据量庞大的时候,为了提高用户体验,将大量数据分成多个页面展示,而不是一次性加载所有内容。本文将详细介绍一个基于jQuery的分页插件,它具有代码简洁、兼容性...
本篇将深入探讨JavaScript实现分页的相关知识点,包括前台分页、客户端分页、分页机制以及相关的JavaScript代码示例。 首先,我们要理解什么是分页。在Web应用中,分页是将大量数据分成多个小部分(每部分通常称为...
在Windows Presentation Foundation (WPF) 中,开发人员经常需要处理大量的数据展示,此时分页功能就显得尤为重要。WPF DataGrid 控件是一个强大的表格展示工具,它可以方便地展示和操作数据,而添加分页功能则可以...
分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码分页代码...
为了解决这个问题,我们可以实现分页功能,让数据分批次加载,从而提高界面响应速度。本文将深入探讨如何在`QTableWidget`和`QTableView`中实现分页栏。 首先,我们需要理解`QTableWidget`和`QTableView`的区别。`...
java实现分页 jsp分页 分页java实现分页 jsp分页 分页java实现分页 jsp分页 分页java实现分页 jsp分页 分页java实现分页 jsp分页 分页java实现分页 jsp分页 分页
2.1.目前网络上很多分页主键,不能进行按钮选择, 2.2.甚至对样式修改的难度也较大, 2.3.使用在开发过程中由于使用到了分页功能,在这里写了一个分页功能。 3.按钮选择 之前的很多按钮是通过参数进行选择,这样不...
在MySQL数据库中,分页是处理大量数据查询时不可或缺的一种技术。它允许用户按需加载数据,而不是一次性获取所有记录,从而提高了用户体验并降低了服务器负载。以下是对分页实现的详细说明: 一、基础概念 分页是将...
在ASP中实现分页功能是常见的需求,特别是在处理大量数据列表时,分页能够提高用户体验,避免一次性加载过多内容导致页面加载缓慢。下面将详细探讨ASP分页的相关知识点。 一、分页的基本原理 分页主要是通过计算总...
**jQuery分页插件及其应用** 在Web开发中,数据量较大的时候,为了提高用户体验,通常会采用分页的方式来展示信息。jQuery分页插件因其轻量级、易用性而受到开发者们的广泛喜爱。本资源包含“最简单分页”至“50种...
### 各数据库分页语法支持 #### 概述 在数据库操作中,分页查询是一项非常常见的需求。分页能够帮助我们有效地管理大量的数据记录,提高数据查询的效率和用户体验。不同的数据库系统提供了不同的分页机制,本文将...
Java 通用分页详解 Java 通用分页是指在Java编程中对大量数据进行分页处理,以提高系统效率和性能。下面对Java通用分页的知识点进行详细说明: 1. 分页的必要性 在实际项目中,数据量可能非常大,直接查询所有...
C# winform分页控件,用于dataGridView分页浏览 `PageControl`是一个为Windows Forms应用程序提供的自定义用户控件,用于实现数据分页显示功能。该控件允许用户通过简单的界面导航不同的数据页,包括首页、上一页、...
Java Swing 表格分页实现 Java Swing 是一个用于构建图形用户界面的 Java 库,提供了丰富的用户界面组件和功能。在本文中,我们将探讨如何使用 Java Swing 实现表格分页。 表格分页的需求 在实际开发中,我们经常...
在MySQL数据库中,分页是实现大量数据查询时不可或缺的功能,它可以帮助用户按需加载数据,提高网页加载速度,减少服务器资源消耗。本篇文章将详细探讨两种常见的分页方法:假分页和LIMIT分页。 首先,我们来理解...
自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签自定义分页标签...
在JavaServer Faces (JSF)框架中,分页是一种常用的技术,用于处理大量数据时提供更好的用户体验。当数据集过大,一次性加载所有记录到页面上会导致性能下降且用户界面响应变慢。通过分页,我们可以将数据分成多个...