<something-else-entirely>
<proxool>
<alias>bpDbCon</alias>
<driver-url>jdbc:microsoft:sqlserver://192.168.39.62:1433;DatabaseName=bpdb</driver-url>
<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
<driver-properties>
<property name="user" value="test"/>
<property name="password" value="test"/>
<property name="useUnicode" value="true"/>
</driver-properties>
<minimum-connection-count>6</minimum-connection-count>
<maximum-connection-count>20</maximum-connection-count>
<prototype-count>6</prototype-count>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</something-else-entirely>
[nId] [int] IDENTITY (1, 1) NOT NULL ,
[strPoNo] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[strGrNo] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[nItem] [int] NOT NULL ,
[strMaterialDesc] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[strMaterialNo] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[strMaterialName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[strApplicant] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[fltUnitPrice] [float] NULL ,
[nCount] [int] NOT NULL ,
[strDate] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[strDeptName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[strSignDate] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[strMaterialSort] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
/*
no_mIss 分页存储过程 2007.2.20 QQ:706716259
适用于单一主键或存在唯一值列的表或视图
*/
@TableName VARCHAR(200), --表名
@FieldList VARCHAR(2000), --显示列名
@PrimaryKey VARCHAR(100), --单一主键或唯一值键
@Where VARCHAR(1000), --查询条件 不含'where'字符
@Order VARCHAR(1000), --排序 不含'order by'字符,如id asc,userid desc,当@SortType=3时生效
@SortType INT, --排序规则 1:正序asc 2:倒序desc 3:多列排序
@RecorderCount INT, --记录总数 0:会返回总记录
@PageSize INT, --每页输出的记录数
@PageIndex INT, --当前页数
@TotalCount INTEGER OUTPUT, --返回记录总数
@TotalPageCount INTEGER OUTPUT --返回总页数
AS
SET NOCOUNT ON
IF ISNULL(@TableName,'') = '' OR ISNULL(@FieldList,'') = ''
OR ISNULL(@PrimaryKey,'') = ''
OR @SortType < 1 OR @SortType >3
OR @RecorderCount < 0 OR @PageSize < 0 OR @PageIndex < 0
BEGIN
RETURN
END
DECLARE @new_where1 VARCHAR(1000)
DECLARE @new_where2 VARCHAR(1000)
DECLARE @new_order VARCHAR(1000)
DECLARE @Sql VARCHAR(8000)
DECLARE @SqlCount NVARCHAR(4000)
IF ISNULL(@where,'') = ''
BEGIN
SET @new_where1 = ' '
SET @new_where2 = ' WHERE '
END
ELSE
BEGIN
SET @new_where1 = ' WHERE ' + @where
SET @new_where2 = ' WHERE ' + @where + ' AND '
END
IF ISNULL(@order,'') = '' OR @SortType = 1 OR @SortType = 2
BEGIN
IF @SortType = 1 SET @new_order = ' ORDER BY ' + @PrimaryKey + ' ASC'
IF @SortType = 2 SET @new_order = ' ORDER BY ' + @PrimaryKey + ' DESC'
END
ELSE
BEGIN
SET @new_order = ' ORDER BY ' + @Order
END
SET @SqlCount = 'SELECT @TotalCount=COUNT(*),@TotalPageCount=CEILING((COUNT(*)+0.0)/'
+ CAST(@PageSize AS VARCHAR)+') FROM ' + @TableName + @new_where1
IF @RecorderCount = 0
BEGIN
EXEC SP_EXECUTESQL @SqlCount,N'@TotalCount INT OUTPUT,@TotalPageCount INT OUTPUT',
@TotalCount OUTPUT,@TotalPageCount OUTPUT
END
ELSE
BEGIN
SELECT @TotalCount = @RecorderCount
END
IF @PageIndex > CEILING((@TotalCount+0.0)/@PageSize)
BEGIN
SET @PageIndex = CEILING((@TotalCount+0.0)/@PageSize)
--这里加一行测试
--print '当前页PageIndex为'+str(@PageIndex)
END
IF @PageIndex = 0 or @PageIndex = 1
--IF @PageIndex = 1 --原始行
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM '
+ @TableName + @new_where1 + @new_order
END
ELSE
BEGIN
IF @SortType = 1
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' > '
+ '(SELECT max(' + @PrimaryKey + ') FROM (SELECT TOP '
+ STR(@PageSize*(@PageIndex-1)) + ' ' + @PrimaryKey
+ ' FROM ' + @TableName
+ @new_where1 + @new_order +' ) AS TMP) '+ @new_order
END
IF @SortType = 2
BEGIN
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' < '
+ '(SELECT MIN(' + @PrimaryKey + ') FROM (SELECT TOP '
+ STR(@PageSize*(@PageIndex-1)) + ' ' + @PrimaryKey
+' FROM '+ @TableName
+ @new_where1 + @new_order + ') AS TMP) '+ @new_order
END
IF @SortType = 3
BEGIN
IF CHARINDEX(',',@Order) = 0 BEGIN RETURN END
SET @Sql = 'SELECT TOP ' + STR(@PageSize) + ' ' + @FieldList + ' FROM '
+ @TableName + @new_where2 + @PrimaryKey + ' NOT IN (SELECT TOP '
+ STR(@PageSize*(@PageIndex-1)) + ' ' + @PrimaryKey
+ ' FROM ' + @TableName + @new_where1 + @new_order + ')'
+ @new_order
END
END
EXEC(@Sql)
--print @Sql
import java.util.Vector;
/**
* Title: 分页类
* Description:
* Copyright: Copyright (c) 2007
* Company: USI
* @author: LJ
* @version 1.0
*/
public class Pagess {
protected Vector list; //物品向量数组
protected int page=1; //当前页数
protected int recordCount=0; //记录总数 0:会返回总记录
protected int pageCount=1; //返回总页数
protected int pageSize=15; //每页输出的记录数
protected int recode=0;
protected int pageMaxCount=0;
protected int listCount=0;
protected boolean showAll=false;
public Pagess() throws Exception{
}
public void setPage(int newPage) {
this.page=newPage;
}
public int getPage() {
if (page<=0)
return 1;
else
return page;
}
public void setPageSize(int newPageSize) {
pageSize=newPageSize;
}
public void setShowAll() {
showAll=true;
}
public int getPageSize() {
return pageSize;
}
public int getPageCount() {
return pageCount;
}
public int getRecordCount() {
return recordCount;
}
public int getRecode() {
return recode;
}
public void setListCount(int listCount){
this.listCount=listCount;
}
public int getListCount() {
return list.size();
}
public Vector getLists() {
return list;
}
public void setShowPage(int newCount) throws Exception {
listCount=newCount;
list = new Vector();//PageMaxCount+1);
list.clear();
recode=(page-1)*pageSize+1;
}
/**
* @param pageCount 要设置的 pageCount
*/
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
/**
* @param recordCount 要设置的 recordCount
*/
public void setRecordCount(int recordCount) {
this.recordCount = recordCount;
}
};
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
/**
* Title: 物品列表
* Description:
* Copyright: Copyright (c) 2007
* Company: USI
* @author: LJ
* @version 1.0
*/
public class Listss extends Pagess {
private String[] columnNames = {};
private ResultSetMetaData metaData;
int row=0;
int columnCount=0;
String strSql="";
int execute=0;
String sql="";
private String poolName;
private String tableName="";
private String fieldList="";
private String primaryKey="";
private String where="";
private String order="";
private int sortType=1;
/**
* @return fieldList
*/
public String getFieldList() {
return fieldList;
}
/**
* @param fieldList 要设置的 fieldList
*/
public void setFieldList(String fieldList) {
this.fieldList = fieldList;
}
/**
* @return order
*/
public String getOrder() {
return order;
}
/**
* @param order 要设置的 order
*/
public void setOrder(String order) {
this.order = order;
}
/**
* @return primaryKey
*/
public String getPrimaryKey() {
return primaryKey;
}
/**
* @param primaryKey 要设置的 primaryKey
*/
public void setPrimaryKey(String primaryKey) {
this.primaryKey = primaryKey;
}
/**
* @return sortType
*/
public int getSortType() {
return sortType;
}
/**
* @param sortType 要设置的 sortType
*/
public void setSortType(int sortType) {
this.sortType = sortType;
//System.out.println(this.sortType);
}
/**
* @return tableName
*/
public String getTableName() {
return tableName;
}
/**
* @param tableName 要设置的 tableName
*/
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* @return where
*/
public String getWhere() {
return where;
}
/**
* @param where 要设置的 where
*/
public void setWhere(String where) {
this.where = where;
}
public Listss() throws Exception{
super();
}
public String getColumnName(int column) {
if (column>=columnCount)
column=columnCount-1;
if (column<0)
column=0;
if (columnNames[column] != null) {
return columnNames[column];
} else
return "";
}
public int getColumnIndex(String name) {
int ok=0;
if (name!=null) {
for (int i=0;i<columnCount;i++) {
String temp=columnNames[i].toLowerCase();
name=name.toLowerCase();
if (name.equals(temp))
{
ok= i;
break;
}
}
}
return ok;
}
public void setRow(int i) {
row=i;
}
public int getRow(){
return this.row;
}
public int getColumnCount() {
return columnNames.length;
}
public Class getColumnClass(int column) {
int type;
try {
type = metaData.getColumnType(column+1);
}
catch (SQLException e) {
return null;
}
switch(type) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
return String.class;
case Types.BIT:
return Boolean.class;
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
return Integer.class;
case Types.BIGINT:
return Long.class;
case Types.FLOAT:
case Types.DOUBLE:
return Double.class;
case Types.DATE:
return java.sql.Date.class;
default:
return Object.class;
}
}
public String getString(int aColumn) {
String[] rowStr = (String[])list.elementAt(row);
return rowStr[aColumn];
// Vector row = (Vector)list.elementAt(FRow);
// return row.elementAt(aColumn).toString();
}
public String getString(String aColumnName) {
String[] rowStr = (String[])list.elementAt(row);
return rowStr[getColumnIndex(aColumnName)];
// Vector row = (Vector)list.elementAt(FRow);
// return row.elementAt(getColumnIndex(aColumnName)).toString();
}
public void setSql(String tableName) {
String Str="";
Str="select * from "+tableName+" order by id desc";
strSql=Str;
}
public void setStrSql(String Str) {
strSql=Str;
}
public String getStrSql(){
return this.strSql;
}
public String getSql() {
return strSql;
}
public int getExecute() throws Exception{
if(excute()) return 1;
else return 0;
}
public boolean excute() throws Exception {
int id = 0;
try {
DBConnect dbc = new DBConnect(this.poolName,"CallableStatement");
CallableStatement cstmt = dbc.getConnection().prepareCall("{call P_viewPage(?,?,?,?,?,?,?,?,?,?,?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
cstmt.setString(1,this.tableName);
cstmt.setString(2,this.fieldList);
cstmt.setString(3,this.primaryKey);
cstmt.setString(4,this.where);
cstmt.setString(5,this.order);
cstmt.setInt(6,this.sortType);
cstmt.setInt(7,super.getRecordCount());
cstmt.setInt(8,super.getPageSize());
cstmt.setInt(9,super.getPage());
cstmt.registerOutParameter(10,java.sql.Types.INTEGER);
cstmt.registerOutParameter(11,java.sql.Types.INTEGER);
//System.out.print(this.tableName+" "+this.fieldList+" "+this.primaryKey+" " +this.where+" "+this.order+" "+this.sortType+" "+super.getRecordCount()+" "+super.getPageSize()+" "+super.getPage());
cstmt.executeUpdate();
super.setRecordCount(cstmt.getInt(10));
super.setPageCount(cstmt.getInt(11));
//System.out.println(cstmt.getInt(10));
//System.out.println(cstmt.getInt(11));
ResultSet rs=cstmt.executeQuery();
//设置当前页
if(super.getPage()>=super.getPageCount()) super.setPage(super.getPageCount());
metaData = rs.getMetaData();
columnCount = metaData.getColumnCount();
columnNames = new String[columnCount];
// Get the column names and cache them.
// Then we can close the connection.
for(int column = 0; column < columnCount; column++) {
columnNames[column] = metaData.getColumnLabel(column+1);
}
//rs.last();
setShowPage(rs.getRow());
//rs.absolute(getRecode());
if(rs.next()){
for (int i=0;i<getPageSize();i++){
String[] rsRow = {};
rsRow = new String[columnCount];
for(int column = 0; column < columnCount; column++) {
rsRow[column] = rs.getString(column+1);
}
list.addElement(rsRow);
// list.addElement(rs.getObject(i));
if (!rs.next())
break;
}
}
rs.close();
cstmt.close();
dbc.close();
return true;
}
catch (SQLException sqle){
sqle.printStackTrace();
return false;
}
}
/**
* @return poolName
*/
public String getPoolName() {
return poolName;
}
/**
* @param poolName 要设置的 poolName
*/
public void setPoolName(String poolName) {
this.poolName = poolName;
}
}
<option value="strPoNo">P/O</option>
<option value="strGrNo">收货GR NO.</option>
<option value="strMaterialNo">物料编号</option>
<option value="strMaterialName">物料名称</option>
<option value="strDate">日期</option>
<option value="nItem">Item</option>
<option value="nCount">数量</option>
<option value="strApplicant">请购人</option>
<option value="strDeptName">所属部门</option>
</select>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查询</title>
</head>
<style type="text/css">
<!--
BODY {
FONT-SIZE: 12px; FONT-FAMILY: "宋体"
}
TD {
FONT-SIZE: 12px; FONT-FAMILY: "宋体"
}
-->
</style>
<script language="JavaScript" src="files/My97DatePicker/WdatePicker.js"></script>
<script language="javascript">
<!--
//日历与普通输入框切换
function onChangeText(){
if(form2.D2.value=="strDate"){
eval("document.getElementById('T2').style.display='block'");
eval("document.getElementById('T1').style.display='none'");
}else{
eval("document.getElementById('T2').style.display='none'");
eval("document.getElementById('T1').style.display='block'");
}
}
//根据条件组合生成SQL语句中的where条件
function query_item()
{
var str2="";
var str3="";
str2 += form2.D2.value + " ";
str2 += form2.D3.value + " ";
if (form2.D3.value=="like")
str2 += "'%" + form2.T1.value + "%'" + " ";
else {
if (form2.D2.value=="nItem"||form2.D2.value=="nCount")
str2 += "" + form2.T1.value + "" + " ";
else{
if(document.getElementById('T2').style.display=='block')
str2 += "'" + form2.T2.value + "'" + " ";
else
str2 += "'" + form2.T1.value + "'" + " "
}
}
str3 = form2.S2.value;
if (str3.search(str2)<0)
{
if (form2.S2.value!="")
str2 = form2.S2.value + form2.D1.value + " " + str2 + " ";
else
//str2 = "where" + " " + str2 + " "
str2 =" " + str2 + " ";
if(document.getElementById('T2').style.display=='block'){
if (form2.T2.value!="")
{
form2.S2.value = str2;
form2.T2.value = "";
}
}else{
if (form2.T1.value!="")
{
form2.S2.value = str2;
form2.T1.value = "";
}
}
}
}
//清空对象
function set_null()
{
form2.D1.options[0].selected
form2.D2.options[0].selected
form2.D3.options[0].selected
form2.T1.value = ""
form2.S2.value = ""
}
//-->
</script>
<body>
<table align="left" width="102%">
<tr>
<td width="24%" height="30" background="p_w_picpaths/opbg.gif"><img src="p_w_picpaths/a.gif">
当前位置:查询
</td>
</tr>
<tr>
<td style="height:60px"></td>
</tr>
<tr>
<td>
<form method="post" action="recordsListResult.jsp" name="form2" >
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" class="search">
<tbody>
<tr>
<td height="30" background="p_w_picpaths/s_02.gif"><img src="p_w_picpaths/s_01.gif" width="284" height="30"></td>
</tr>
<tr>
<td bgcolor="#f1f4f5" height="32">
<table>
<tr>
<td width="64">
<select size="1" name="D1">
<option value="and">并且</option>
<option value="or">或者</option>
</select>
</td>
<td width="39">
字段:
</td>
<td width="83">
<select size="1" name="D2" onChange="javascript:onChangeText();">
<option value="strPoNo">P/O</option>
<option value="strGrNo">收货GR NO.</option>
<option value="strMaterialNo">物料编号</option>
<option value="strMaterialName">物料名称</option>
<option value="strDate">日期</option>
<option value="nItem">Item</option>
<option value="nCount">数量</option>
<option value="strApplicant">请购人</option>
<option value="strDeptName">所属部门</option>
</select>
</td>
<td width="61">
查询条件:
</td>
<td width="77">
<select size="1" name="D3">
<option selected value="=">等于</option>
<option value=">">大于</option>
<option value="<">小于</option>
<option value="like">类似</option>
</select>
</td>
<td width="145">
<input type="text" name="T1" id="T1" size="20">
<input type="text" name="T2" id="T2" size="20" style="display:none" class="Wdate" onFocus="new WdatePicker(this)">
</td>
<td width="95">
<input type=button value="确定" name="B1"
<input type=button value="清除" name="B2"
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="38">
<textarea rows="3" name="S2" cols="80" style="font-family: 宋体; font-size: 9pt" readonly></textarea>
<input type="p_w_picpath" src="p_w_picpaths/sear1.gif" name="sm1">
</td>
</tr>
</tbody>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
本页功能说明
该jsp模板是最简单的view实现的一个例子,主要根据上个页面查询的得到的where条件进行数据的分页显示
由于不含Form,实现起来较简单,开发者可以直接通过“引入”及“配置”来完成页面设计
需要更改的地方以******标记标出
--------------------------------------->
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<!----------------------------------------
jsp:useBean id="list1" scope="request" class="sqlDBconnect.Listss" 的说明:
javaBean,后台用存储过程实现分页,该类完成分页存储过程参数的传递,且该类与应用无关!
------------------------------------------>
<jsp:useBean id="list1" scope="request" class="sqlDBconnect.Listss" />
<html:html lang="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>显示</title>
<html:base/>
<style type="text/css">
<!--
BODY {
FONT-SIZE: 12px; FONT-FAMILY: "宋体"
}
TD {
FONT-SIZE: 12px; FONT-FAMILY: "宋体"
}
-->
</style>
<link href="css/barStyle.css" rel="stylesheet" type="text/css">
<link href="css/search1.css" rel="stylesheet" type="text/css">
<link href="css/css1.css" rel="stylesheet" type="text/css">
<link href="css/ny.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#fffff7" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<script language="JavaScript">
//分页跳转
function Jumping(){
document.PageForm.submit();
return ;
}
</script>
<table align="left" width="102%">
<tr>
<td width="24%" height="30" background="p_w_picpaths/opbg.gif"><img src="p_w_picpaths/a.gif">
当前位置:查询结果
</td>
</tr>
<tr>
<td style="height:60px"></td>
</tr>
<tr>
<td>
<!--1,****************************************
c:set var="selfweb" value="recordsListResult" scope="request" 说明:
JSP中JSTL标签,生成request范围内的一个对象,主要为了指定devPage.jsp中的跳转页面,开发者应该根据不
同的显示页面为对象指定不同的值,一般是当前页名,注意不要带扩展名.
*******************************************-->
<c:set var="selfweb" value="recordsListResult" scope="request"/>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#b6bfdc" bgcolor="#b6bfdc" class="search">
<!--2,********************************************
td height="21" colspan="12" 说明:
首行应该显示的列数,根据需要确定要显示的列数,适时更改colspan的值
***********************************************-->
<tr bgcolor="#FFFFFF" >
<td height="21" colspan="12"><img src="p_w_picpaths/sea.gif" width="354" height="21"></td>
</tr>
<tr class="bar1">
<!--3,*******************************************
要显示的列信息说明
这是数据表中应该显示出来给用户查看的列名及相关信息,根据需要显示,不必全部列出
*********************************************-->
<td width="8%" align="center" >P/O</td>
<td width="8%" align="center" >GR NO.</td>
<td width="8%" align="center" >物料编号</td>
<td width="9%" align="center" >物料名称</td>
<td width="9%" align="center" >日期</td>
<td width="6%" align="center">Item</td>
<td width="6%" align="center">数量</td>
<td width="7%" align="center">单价</td>
<td width="7%" align="center">请购人</td>
<td width="8%" align="center">所属部门</td>
<td width="8%" align="center">签收日期</td>
<td width="16%" align="center">物料描述</td>
</tr>
<!--4,************************
分页存储过程的一些参数
PageSize 规定每页应该显示多少条记录,默认20条,可以根据需要自行更改
ShowPage 当前显示第几页,初始化时默认显示第一页
PageCount 应该显示的页数,该值会根据前两个参数由系统自动更新
*************************-->
<c:set var="PageSize" scope="request" value="20"/>
<c:set var="ShowPage" scope="request" value="1"/>
<c:set var="PageCount" scope="request" value="0"/>
<%
//receive the parameter from the previousPage and nextPage
String Page=request.getParameter("page");
request.setAttribute("Page",Page);
%>
<logic:notEmpty name="Page">
<c:set var="ShowPage" scope="request">
<c:out value="${Page}"/>
</c:set>
</logic:notEmpty>
<!--set the property of List-->
<c:set target="${list1}" property="pageSize">
<c:out value="${PageSize}"/>
</c:set>
<c:set target="${list1}" property="page">
<c:out value="${ShowPage}"/>
</c:set>
<!--5,************************************
由查询页面传入的查询条件的说明
接收到的S2为上一个查询页面传入的查询条件,可以将此查询条件和其它信息进行组合生成最终的SQL
Where条件。
**************************************-->
<%
String S2=request.getParameter("S2") ;
if(S2!=null)
session.setAttribute("S2",S2);
%>
<!--6,**************************************
分页类Listss参数的说明
poolName 数据库连接池名,为proxool.xml配置的数据库连接池的别名
tableName 当前Jsp页面要显示的数据表名
fieldList 要用到数据表中的哪些字段,列出这些字段名,以逗号作为分隔符
primaryKey 数据表中以哪个字段作为主键
order 排序 不含'order by'字符,如nId desc,strPoNo asc,当SortType=3时生效
sortType 排序规则 1:正序asc 2:倒序desc 3:多列排序,如果取1或2则是对主键排序
******************************************-->
<c:set target="${list1}" property="poolName" value="bpDbCon"/>
<c:set target="${list1}" property="tableName" value="recordsList"/>
<c:set target="${list1}" property="fieldList" value="strPoNo,strGrNo,strDate,nItem,nCount,fltUnitPrice,strApplicant,strMaterialDesc,strMaterialNo,strMaterialName,strDeptName,strSignDate"/>
<c:set target="${list1}" property="primaryKey" value="nId"/>
<!--if the "S2" var is not null,set the strSql property of List-->
<logic:notEmpty name="S2">
<c:set target="${list1}" property="where">
<c:out escapeXml="false" value="${S2}"/>
</c:set>
</logic:notEmpty>
<c:set target="${list1}" property="order" value=""/>
<c:set target="${list1}" property="sortType" value="2"/>
<c:if test="${list1.execute==1}">
<c:set var="ShowPage" scope="request">
<c:out value="${list1.page}"/>
</c:set>
<c:set var="PageCount" scope="request">
<c:out value="${list1.pageCount}"/>
</c:set>
<c:set var="PageSize" scope="request">
<c:out value="${list1.pageSize}"/>
</c:set>
<c:forEach var="i" begin="0" end="${list1.pageSize-1}" step="1">
<c:set var="Class" value="search3"/>
<c:if test="${i%2==0}">
<c:set var="Class" value="search4"/>
</c:if>
<c:if test="${i<list1.listCount}">
<c:set target="${list1}" property="row">
<c:out value="${i}"/>
</c:set>
<!--7,****************************************
取出要显示的列值
不管是int,String,float,double等都可以list1.getString()来取值,传入参数为上面所列出的数据表中字段名
******************************************-->
<tr class='<c:out value="${Class}"/>' onmouseover="this.style.backgroundColor='#dae2ed'" onmouseout="this.style.backgroundColor=''">
<td align="center"><%=list1.getString("strPoNo")%></td>
<td align="center"><%=list1.getString("strGrNo")%></td>
<td align="center"><%=list1.getString("strMaterialNo")%></td>
<td align="center"><%=list1.getString("strMaterialName")%></td>
<td align="center"><%=list1.getString("strDate")%></td>
<td align="center"><%=list1.getString("nItem")%></td>
<td align="center"><%=list1.getString("nCount")%></td>
<td align="center"><%=list1.getString("fltUnitPrice")%></td>
<td align="center"><%=list1.getString("strApplicant")%></td>
<td align="center"><%=list1.getString("strDeptName")%></td>
<td align="center"><%=list1.getString("strSignDate")%></td>
<td align="center"><%=list1.getString("strMaterialDesc")%></td>
</tr>
</c:if>
</c:forEach>
</c:if>
<tr onmouseover="this.style.backgroundColor='#dae2ed'" onmouseout="this.style.backgroundColor=''">
<td colspan="12">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!-------------------------------------
引入分页脚本
--------------------------------------->
<%@ include file="devPage.jsp"%>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html:html>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<form method="post" action='<c:out value="${selfweb}"/>.jsp' name="PageForm">
<tr>
<td class="search4" width="100%" height="100%">
<img src="p_w_picpaths/y1.gif" width="5" height="7">
<a href='<c:out value="${selfweb}"/>.jsp?' target="_self">第一页</a>
<c:if test="${ShowPage==1}">
<img src="p_w_picpaths/y2.gif" width="4" height="7">前一页
</c:if>
<c:if test="${ShowPage!=1}">
<img src="p_w_picpaths/y2.gif" width="4" height="7">
<%request.setAttribute("prev",String.valueOf(Integer.parseInt(request.getAttribute("ShowPage").toString())-1));%>
<a href='<c:out value="${selfweb}"/>.jsp?page=<c:out value="${prev}"/>' target="_self">前一页</a>
</c:if>
<c:if test="${ShowPage==PageCount}"> <img src="p_w_picpaths/y3.gif" width="4" height="7">下一页
</c:if>
<c:if test="${ShowPage!=PageCount}"> <img src="p_w_picpaths/y3.gif" width="4" height="7">
<%request.setAttribute("next",String.valueOf(Integer.parseInt(request.getAttribute("ShowPage").toString())+1));%>
<a href='<c:out value="${selfweb}"/>.jsp?page=<c:out value="${next}"/>' target="_self">下一页</a>
</c:if>
<img src="p_w_picpaths/y4.gif" width="5" height="7"><a href='<c:out value="${selfweb}"/>.jsp?page=<c:out value="${list1.pageCount}"/>' target="_self">最后一页</a>
记录总数<c:out value="${list1.recordCount}"/>
每页<c:out value="${PageSize}"/>
当前页[<c:out value="${ShowPage}"/>/<c:out value="${list1.pageCount}"/>页]
页数
<select name="page" onchange="Jumping()" style="width:50px">
<c:if test="${ShowPage!=0}">
<option value='<c:out value="${ShowPage}"/>'><c:out value="${ShowPage}"/></option>
</c:if>
<c:if test="${list1.pageCount>=1}">
<c:forEach var="i" begin="1" end="${list1.pageCount}" step="1">
<option value='<c:out value="${i}"/>'><c:out value="${i}"/></option>
</c:forEach>
</c:if>
</select>
</td>
</tr>
</form>
<option value="strPoNo">P/O</option>
<option value="strGrNo">收货GR NO.</option>
<option value="strMaterialNo">物料编号</option>
<option value="strMaterialName">物料名称</option>
<option value="strDate">日期</option>
<option value="nItem">Item</option>
<option value="nCount">数量</option>
<option value="strApplicant">请购人</option>
<option value="strDeptName">所属部门</option>
</select>