一下是我的代码,没法显示数据:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<title>无标题文档</title>
</head><body>
<p> </p>
<p> </p>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><form id="form1" name="form1" method="post" action="">
<table width="691" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="691" height="40" align="center" class="YGTitle">员工列表</td>
</tr>
<tr>
<td><table width="537" height="37" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td width="533"><table width="554" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="554" height="10" align="center" class="YGStitle"></td>
</tr>
<tr>
<td height="10" align="center" class="YGStitle">
<jsp:useBean id="mydb" class="MyBean.DB" scope="page" />
<table width="572" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="49" height="25" align="center" class="YGScontnt">ID</td>
<td width="93" height="25" align="center" class="YGScontnt">员工编号</td>
<td width="118" align="center" class="YGScontnt">员工姓名</td>
<td width="101" align="center" class="YGScontnt">性别</td>
<td width="135" align="center" class="YGScontnt">所在部门</td>
<td width="76" height="25" align="center" class="YGScontnt">查询</td>
</tr>
<%
String Depart=request.getParameter("Depart");
String Sname=request.getParameter("Sname");
int nowPages=0;//当前页
int pages=0;//请求页数
int countPerPage = 10 ; //每页显示条数
int recordCount=0;
int pageCount=0;//总页数
try{
ResultSet rset = mydb.executeQuery("SELECT count(*) FROM Depart INNER JOIN YG_Infor ON Depart.BMID = YG_Infor.BMID INNER JOIN YGZLiao ON YG_Infor.YGID = YGZLiao.YGID WHERE (Depart.BMID = '"+Depart+"') AND (YGZLiao.YGName LIKE '%"+Sname+"%')");
while(rset.next()){
recordCount = rset.getInt(1); //recordCount为总记录数
}
rset.close();
//System.out.print(recordCount);
}catch(Exception e)
{
e.getMessage();
}
pageCount = (int)Math.ceil((recordCount + countPerPage-1) / countPerPage);//算出总页数
if(request.getParameter("pages") == null){
pages = 1;
}else{
pages = new Integer(request.getParameter("pages")).intValue();
}
//得到当前实际页面
if(pages > pageCount){
nowPages = 1;
}else{
nowPages = pages;
}
int i=0;
//int j=0;
int thepage=(nowPages-1)*countPerPage;
try{
String sql="SELECT * FROM Depart INNER JOIN YG_Infor ON Depart.BMID = YG_Infor.BMID INNER JOIN YGZLiao ON YG_Infor.YGID = YGZLiao.YGID WHERE (Depart.BMID = '"+Depart+"') AND (YGZLiao.YGName LIKE '%"+Sname+"%')";
//System.out.print(sql);
//System.out.print(countPerPage);
ResultSet rs=mydb.executeQuery(sql);
rs.absolute(nowPages);
while(rs.next())
{
String YGID=rs.getString("YGID");
String YGName=rs.getString("YGName");
String Sex=rs.getString("Sex");
String DepartName=rs.getString("DepartName");
//System.out.print(YGID);
if((i%2)==0)
{
%>
<tr>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(i); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(YGID); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(YGName); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(Sex); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(DepartName);%></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><img src="img/b3.gif" width="16" height="16" /></td>
</tr>
<%
}
else if((i%2)==1)
{
%>
<tr>
<td height="25" align="center" class="dashline"><%out.println(i); %></td>
<td height="25" align="center" class="dashline"><%out.println(YGID); %></td>
<td height="25" align="center" class="dashline"><%out.println(YGName); %></td>
<td height="25" align="center" class="dashline"><%out.println(Sex); %></td>
<td height="25" align="center" class="dashline"><%out.println(DepartName);%></td>
<td height="25" align="center" class="dashline"><img src="img/b3.gif" width="16" height="16" /></td>
</tr>
<%
}
i++;
}
rs.close();
}catch(Exception ex)
{
ex.getMessage();
}
%>
<tr align="right">
<td colspan="6">共有<font color=red><%= recordCount %></font>条记录 当前<font color=red><%= nowPages %>/<%= pageCount %></font>页
<% if(pageCount > 1){ %>
<% if(pages > 1){%>
<a href="">首页</a>
<%}if(pages < pageCount){%>
<a href="LookYGong.jsp?pages=<%= nowPages+1 %>">下一页</a>
<%}if(pages != 1){%>
<a href="LookYGong.jsp?pages=<%= nowPages - 1 %>">上一页</a>
<%}%>
<a href="LookYGong.jsp?pages=<%= pageCount %>">尾页</a>
<% } %>跳转到
<select name="pages" onChange="javascript:this.form.submit();">
<% for(int w=1;w<=pageCount;w++){%>
<option value="<%= w %>" <% if(nowPages == w){%>selected<% } %>><%= w %></option>
<% }
%>
</select>页</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<title>无标题文档</title>
</head><body>
<p> </p>
<p> </p>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><form id="form1" name="form1" method="post" action="">
<table width="691" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="691" height="40" align="center" class="YGTitle">员工列表</td>
</tr>
<tr>
<td><table width="537" height="37" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td width="533"><table width="554" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="554" height="10" align="center" class="YGStitle"></td>
</tr>
<tr>
<td height="10" align="center" class="YGStitle">
<jsp:useBean id="mydb" class="MyBean.DB" scope="page" />
<table width="572" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="49" height="25" align="center" class="YGScontnt">ID</td>
<td width="93" height="25" align="center" class="YGScontnt">员工编号</td>
<td width="118" align="center" class="YGScontnt">员工姓名</td>
<td width="101" align="center" class="YGScontnt">性别</td>
<td width="135" align="center" class="YGScontnt">所在部门</td>
<td width="76" height="25" align="center" class="YGScontnt">查询</td>
</tr>
<%
String Depart=request.getParameter("Depart");
String Sname=request.getParameter("Sname");
int nowPages=0;//当前页
int pages=0;//请求页数
int countPerPage = 10 ; //每页显示条数
int recordCount=0;
int pageCount=0;//总页数
try{
ResultSet rset = mydb.executeQuery("SELECT count(*) FROM Depart INNER JOIN YG_Infor ON Depart.BMID = YG_Infor.BMID INNER JOIN YGZLiao ON YG_Infor.YGID = YGZLiao.YGID WHERE (Depart.BMID = '"+Depart+"') AND (YGZLiao.YGName LIKE '%"+Sname+"%')");
while(rset.next()){
recordCount = rset.getInt(1); //recordCount为总记录数
}
rset.close();
//System.out.print(recordCount);
}catch(Exception e)
{
e.getMessage();
}
pageCount = (int)Math.ceil((recordCount + countPerPage-1) / countPerPage);//算出总页数
if(request.getParameter("pages") == null){
pages = 1;
}else{
pages = new Integer(request.getParameter("pages")).intValue();
}
//得到当前实际页面
if(pages > pageCount){
nowPages = 1;
}else{
nowPages = pages;
}
int i=0;
//int j=0;
int thepage=(nowPages-1)*countPerPage;
try{
String sql="SELECT * FROM Depart INNER JOIN YG_Infor ON Depart.BMID = YG_Infor.BMID INNER JOIN YGZLiao ON YG_Infor.YGID = YGZLiao.YGID WHERE (Depart.BMID = '"+Depart+"') AND (YGZLiao.YGName LIKE '%"+Sname+"%')";
//System.out.print(sql);
//System.out.print(countPerPage);
ResultSet rs=mydb.executeQuery(sql);
rs.absolute(nowPages);
while(rs.next())
{
String YGID=rs.getString("YGID");
String YGName=rs.getString("YGName");
String Sex=rs.getString("Sex");
String DepartName=rs.getString("DepartName");
//System.out.print(YGID);
if((i%2)==0)
{
%>
<tr>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(i); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(YGID); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(YGName); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(Sex); %></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><%out.println(DepartName);%></td>
<td height="25" align="center" bgcolor="#eeeeee" class="dashline"><img src="img/b3.gif" width="16" height="16" /></td>
</tr>
<%
}
else if((i%2)==1)
{
%>
<tr>
<td height="25" align="center" class="dashline"><%out.println(i); %></td>
<td height="25" align="center" class="dashline"><%out.println(YGID); %></td>
<td height="25" align="center" class="dashline"><%out.println(YGName); %></td>
<td height="25" align="center" class="dashline"><%out.println(Sex); %></td>
<td height="25" align="center" class="dashline"><%out.println(DepartName);%></td>
<td height="25" align="center" class="dashline"><img src="img/b3.gif" width="16" height="16" /></td>
</tr>
<%
}
i++;
}
rs.close();
}catch(Exception ex)
{
ex.getMessage();
}
%>
<tr align="right">
<td colspan="6">共有<font color=red><%= recordCount %></font>条记录 当前<font color=red><%= nowPages %>/<%= pageCount %></font>页
<% if(pageCount > 1){ %>
<% if(pages > 1){%>
<a href="">首页</a>
<%}if(pages < pageCount){%>
<a href="LookYGong.jsp?pages=<%= nowPages+1 %>">下一页</a>
<%}if(pages != 1){%>
<a href="LookYGong.jsp?pages=<%= nowPages - 1 %>">上一页</a>
<%}%>
<a href="LookYGong.jsp?pages=<%= pageCount %>">尾页</a>
<% } %>跳转到
<select name="pages" onChange="javascript:this.form.submit();">
<% for(int w=1;w<=pageCount;w++){%>
<option value="<%= w %>" <% if(nowPages == w){%>selected<% } %>><%= w %></option>
<% }
%>
</select>页</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货