日期:2014-05-18  浏览次数:20726 次

在JSP页面中实现检索数据的分页显示不知道问题出在哪里,就是没有办法点下一页
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/TR/REC-html40/strict.dtd">
<%@page contentType="text/html;charset=shift_JIS" language="java" import="java.sql.*,java.io.*,java.text.*,java.util.*,javax.servlet.jsp.*" %>
<%!String trans(String chi)
<% 
request.setCharacterEncoding("shift_JIS");
java.sql.Connection sqlCon;
java.sql.Statement sqlStmt;
java.sql.ResultSet sqlRst;
java.lang.String strCon;
java.lang.String strSQL;
java.lang.String strPage;
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
int i;
  //从上一页文本框内获取要检索的信息
String id = request.getParameter("id");
String nm = request.getParameter("nm");
String age = request.getParameter("age");
String sectioncd = request.getParameter("sectioncd");
String tel = request.getParameter("tel");
String email = request.getParameter("email");
String reday1 = request.getParameter("reday1");
String reday2 = request.getParameter("reday2");
String upday1 = request.getParameter("upday1");
String upday2 = request.getParameter("upday2");

intPageSize=20;
strPage=request.getParameter("page");
if(strPage==null)
{
intPage=1;
}
else
{
intPage=java.lang.Integer.parseInt(strPage);
if(intPage<1)
intPage=1;
}
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
strCon="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=TEST";
sqlCon=java.sql.DriverManager.getConnection(strCon,"test","test01");
sqlStmt=sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
strSQL="select * from M_USER,M_SECTION where (M_USER.SECTIONCD=M_SECTION.SECTIONCD) and ( (M_USER.USERCD like '%"+id+"' or M_USER.USERCD like '%"+id+"%') and (M_USER.NM like '%"+nm+"%') and (M_USER.AGE like '%"+age+"%' or AGE = '"+age+"') and (M_USER.SECTIONCD like '%"+sectioncd+"%') and (M_USER.TEL like '"+tel+"%' or M_USER.TEL like '%"+tel+"%') and (M_USER.EMAIL like '%"+email+"%') and ((M_USER.REG_DT between '"+reday1+"' and '"+reday2+"' or (M_USER.REG_DT >= '"+reday1+"' and M_USER.REG_DT like '%"+reday2+"%')) or (M_USER.REG_DT like '%"+reday1+"%' and M_USER.REG_DT like '%"+reday2+"%')) and ((M_USER.UP_DT between '"+upday1+"' and '"+upday2+"' or (M_USER.UP_DT >= '"+upday1+"' and M_USER.REG_DT like '%"+upday2+"%')) or (M_USER.UP_DT like '%"+upday1+"%' and M_USER.UP_DT like '%"+upday2+"%'))) order by M_USER.USERCD;";
sqlRst=sqlStmt.executeQuery(strSQL);
sqlRst.last();
intRowCount=sqlRst.getRow();
intPageCount=(intRowCount+intPageSize-1)/intPageSize;
if(intPage>intPageCount)
intPage=intPageCount;

 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=shift_JIS">
<title>ページの処理</title>
</head>
<LINK href="hellking.css" type=text/css tel=stylesheet>
<body topmargin="50px" leftmargin="30px">
<form method="POST" action="searchbottom.jsp">
<%=(intPage-1)*intPageSize+1%>/<%=intRowCount%>
<% if(intPage>1){ %>
<a href="searchbottom.jsp?page=1">先 頭</a>
<% }