您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > JSP >

一个通用的JSP分页程序

来源:未知 责任编辑:智问网络 发表时间:2013-09-22 21:28 点击:

//本程序使用了一个类反射的类,可以自动将查询出来的值填充到值对象里。
//这个类可以参见ibm的文章:使用类反射机制简化struts的开发.

package com.lyjWeb.wyhn.common;


import java.sql.*;
import com.lyjWeb.common.*;
import java.util.*;

public class Fenye {
 
 private Connection con=null;
 private String sql="";
 private String page="1";// 当前页 
 private int i_page=1;//当前页
 private int i_page_count=10;//每页显示条数
 private String nextpage,prepage,sumpage,sumcount;
 
 private String sql_select,sql_from,sql_where,sql_order;
 private String sql_pre="";
 private String sql_count=""; //count(*)语句
 private ResultSet rst=null;
 private PreparedStatement stm=null;
 
 private Collection result_c=null;
 
 private String s_null="无";
 
///////////////////////////输入值///////////////////////////////
 public void setConnection(Connection con)
 {
  this.con=con;
 }

 public void setSql(String sql_select,String sql_from,String sql_where,String sql_order)
 {
  //this.sql=sql;
  this.sql_select=sql_select;
  this.sql_from=sql_from;
  this.sql_where=sql_where;
  this.sql_order=sql_order;
  this.sql_count="select count(*) " + sql_from + " " + sql_where;
  this.sql=sql_select + " " + sql_from + " " + sql_where + " " + sql_order;
 }
 
 public void setStm(PreparedStatement stm)
 {
  this.stm=stm;
 }
 
 public void setPage(String p)
 {
  if(p==null)
  {
   this.page="1";
    this.i_page=1;
  }
  else
  {
   p=p.trim();
   if(p.equals("")) p="1";
   this.page=p;
   this.i_page=Integer.parseInt(this.page);  
  }
  
 }
 
 public void setPageCount(int pcount)
 {
  this.i_page_count=pcount;
 }

 public void setSqlPre(String sqlpre)
 {
  this.sql_pre=sqlpre; 
 }

 public void setS_null(String s_null)
 {
  this.s_null=s_null;
 }
//////////////////////////////////////返回值/////////////////////////////////////////// 
 public ResultSet getRst()
 {
  return rst;
 }
 
 public String getPage()
 {
  return page;
 }

 public String getNextPage()
 {
  return nextpage;
 }
 
 public String getPrePage()
 {
  return prepage;
 }
 
 public String getSumPage()
 {
  return sumpage;
 }
 
 public String getCount()
 {
  return sumcount;
 }
 
 public Collection getCollection()
 {
  return result_c;
 }
 
////////////////////////////////////////操  作///////////////////////////////////////////////
 private String b_string,f_string;
 private String comsql;
 
 private void CountPage() throws Exception

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • JSP与Servlet
    • 自己动手写MiniBBS系列(基本篇)之用户登录
    • JSP取当前日期
    • JDBC 入门(一)
    • 打开一个jsp页面默认查询所有数据,调用action
    • 使用JSP标签库验证用户的输入(2)完
    • WIN98/2000下的jsp服务器
    • 自定义JSP标签(tag)浅议
    • Struts学习傻瓜式入门篇
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1