<%@?page?language="java"?pageEncoding="UTF-8"%>
<%@?page?import="java.util.*"%>//下面這些是導包和javabean
<%@?page?import="Bean.PersoninfoForm"%>
<jsp:useBean?id="FyeBean"
?class="Dao.FenyeAction"?scope="page"></jsp:useBean>
<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
<html:html?locale="true">
<head>
?<html:base?/>
?<title>查詢</title>
?<meta?http-equiv="pragma"?content="no-cache">
?<meta?http-equiv="cache-control"?content="no-cache">
?<meta?http-equiv="expires"?content="0">
?<meta?http-equiv="keywords"?content="keyword1,keyword2,keyword3">
?<meta?http-equiv="description"?content="This?is?my?page">
?<!--
?<link?rel="stylesheet"?type="text/css"?href="styles.css">
?-->
</head>
<body>
?
?<%
??//變量聲明?
??int?intPageSize;?//一頁顯示的記錄數?
??int?intRowCount;?//記錄總數?
??int?intPageCount;?//總頁數?
??int?intPage;?//待顯示頁碼?
??java.lang.String?strPage;
??int?i;
??//設置一頁顯示的記錄數?
??intPageSize?=?4;
??//取得待顯示頁碼?
??strPage?=?request.getParameter("page");
??if?(strPage?==?null)?{//表明在QueryString中沒有page這一個參數,此時顯示第一頁數據?
???intPage?=?1;
??}?else?{//將字符串轉換成整型?
???intPage?=?java.lang.Integer.parseInt(strPage);
???if?(intPage?<?1)
????intPage?=?1;
??}
??intRowCount?=?FyeBean.count();//獲得總記錄數。用javabean調用了FenyeAction中的方法,得到總記錄數,?
??//記算總頁數?
??intPageCount?=?(intRowCount?+?intPageSize?-?1)?/?intPageSize;
??//調整待顯示的頁碼,如果大于總頁數就等于總頁數?
??if?(intPage?>?intPageCount)
???intPage?=?intPageCount;
?%>
?<form?method="POST"?action="chaxun.jsp">
??<p>
???第
???<%=intPage%>
???頁?共
???<%=intPageCount%>
???頁
???
???<%
??if?(intPage?<?intPageCount)?{
??%>
???<a?href="chaxun.jsp?page=<%=intPage?+?1%>">下一頁?</a>
???<%
???}
???%>
???<%
???if?(intPage?>?1)?{
???%>
???<a?href="chaxun.jsp?page=<%=intPage?-?1%>">?上一頁</a>
???<%
???}
???%>
???轉到第:
???<input?type="text"?name="page"?size="8">
???頁
???<span>?<input?class=buttonface?type="submit"?value="GO"
?????name="cndok">?</span>
??</p>
??<table?width="169"?border="1"?cellpadding="0"?cellspacing="0">
???<tr>
????<th?width="28">
?????車牌
????</th>
????<th?width="82">
?????車型
????</th>
????<th?width="51"?>
?????狀態
????</th>
????<th?width="51"?>
?????用戶
????</th>
????<th?width="51"?>
?????日期
????</th>
????<th?width="51"?>
?????產地
????</th>
???</tr>
???<%
???//查詢數據庫,獲得記錄數據
???Collection?c;
???PersoninfoForm?psinfo;
???c?=?FyeBean.fenye();
???Object?o[]?=?c.toArray();
???
???System.out.println(intPage);//測試用
???System.out.println(intPageSize);
???System.out.println(intPageCount);
???int?start?=?(intPage?-?1)?*?(intPageSize);
???int?end?=?(intPage?-?1)?*?(intPageSize)?+?intPageSize;
???int?j;
????for?(j?=?start;?j?<?end;?j++)?{
?????psinfo?=?(PersoninfoForm)?o[j];
?????String?busNum?=?psinfo.getBusNum();
?????String?busType?=?psinfo.getBusType();
?????String?busStatus?=?psinfo.getBusStatus();
?????String?busUser?=?psinfo.getBusUser();
?????String?busDate?=?psinfo.getBusDate();
?????String?busPlace?=?psinfo.getBusPlace();
???%>
???<tr>
????<td>
?????<%=busNum%>
????</td>
????<td>
?????<%=busType%>
????</td>
????<td>
?????<%=busStatus%>
????</td>
????<td>
?????<%=busUser%>
????</td>
????<td>
?????<%=busDate%>
????</td>
????<td>
?????<%=busPlace%>
????</td>
???</tr>
???<%
???}
???%>
??</table>
?</form>
</body>
</html:html>
添加回答
舉報
0/150
提交
取消