易截截图软件、单文件、免安装、纯绿色、仅160KB

java怎么实现分页

1.PaginationTable.java
package com.sinoest.train.common;
import java.util.List;
/**
* 分页表
* @author 李易烜-修改
* 2009-6-17
*/
public class PaginationTable {
private List<?> entryList;//> 数据
private int totalNumOfRows;// 总行数
private int rowsPerPage = 10;// 每页行数
private int beginIndex = 0;//---> 当前页起始行
private int endIndex;//-----> 终止页
private int pageIndex;//----> 当前页
private int pageCount;//----> 总页数
public PaginationTable(){ }
public PaginationTable(int totalNumOfRows, int pageIndex) {
//super();
if(pageIndex<=0){
pageIndex=1;
}
this.totalNumOfRows = totalNumOfRows;
if(totalNumOfRows%rowsPerPage==0){
this.pageCount = this.totalNumOfRows/rowsPerPage;
}else {
this.pageCount = this.totalNumOfRows/rowsPerPage+1;
}
if(pageIndex > pageCount){
pageIndex = pageCount;
}
this.pageIndex = pageIndex;
if(totalNumOfRows > 0){
this.beginIndex = (pageIndex-1)*rowsPerPage;
}
this.endIndex = pageIndex*rowsPerPage;
endIndex = endIndex>this.totalNumOfRows ? this.totalNumOfRows : endIndex;
}

public PaginationTable(int rowsPerPage, int totalNumOfRows, int pageIndex) {
//super();
this.rowsPerPage = rowsPerPage;
if(pageIndex<=0){
pageIndex=1;
}
this.totalNumOfRows = totalNumOfRows;
if(totalNumOfRows%rowsPerPage==0){
this.pageCount = this.totalNumOfRows/rowsPerPage;
}else {
this.pageCount = this.totalNumOfRows/rowsPerPage+1;
}
if(pageIndex > pageCount){
pageIndex = pageCount;
}
this.pageIndex = pageIndex;
if(totalNumOfRows > 0){
this.beginIndex = (pageIndex-1)*rowsPerPage;
}
this.endIndex = pageIndex*rowsPerPage;
endIndex = endIndex>this.totalNumOfRows ? this.totalNumOfRows : endIndex;
}

/** 总页数,最少一页,0行也按一页计算 */
public int getTotalNumOfPage() {
return this.totalNumOfRows / this.rowsPerPage + 1;
}

/** 数据 */


相关文档:

都是编码惹的祸 java编程

    最近在用润乾在做一些web项目的报表,其中有一个批量打印的报表。需要把参数传到报表里,当把中文传到里面时总时乱码,采用了各种转码方式,也没转过来,晕.........
为什么会有这么多的编码,好头疼呀... ......

JAVA规范学习——String字面常量

package testPackage;
class Test {
public static void main(String[] args) {
String hello = "Hello", lo = "lo";
System.out.print((hello == "Hello") + " ");
System.out.print((Other.hello == hello) + " ");
System.out.print((other.Other.hello == hello) + " ");
System.out.print((hello == ("Hel"+"lo ......

Java线程同步示例

文章用实例代码展示了Java中多线程访问共享资源
时线程同步
的重要性。
分别通过在两个线程中同时访问(调用get_id*方法)经过同步处理(lock及Synchronized)的共享资源(tmp)及未经过同步处理的共享资源(tmp)来说明同步处理的的作用。
main中分两部分:
1)前半部分,non-synchronization部分用来测试没有做同步处理的代码 ......

Java Read()阻塞的一种处理方式

java.io.InputStream的read()方法描述:
        If no byte is available because the end of the stream has been reached, the value -1 is returned.
        到达流的末尾真会放回-1吗?
        ......

java文件比例缩小放大

1首先添加修改图片宽度和高度的方法
public static void reduceImg(String imgsrc, int widthdist, int heightdist) {
  try {
   File srcfile = new File(imgsrc);
   if (!srcfile.exists()) {
    return;
   }
    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号