<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.modorn.Bean.UserDao"%>
<%@page import="com.modorn.Bean.UserBean"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'manger.jsp' starting page</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">
-->
<style type="text/css">
table{ border-collapse:collapse; }
td{ border:#ccc solid 1px; padding:5px; }
</style>
</head>
<body>
<%!int pageNow = 1;%>
<%
String userName = (String) request.getSession().getAttribute("userName");
if (userName == null) {
response.sendRedirect("login.jsp?erro=1");
}
if (request.getParameter("pageNow") != null) {
pageNow = Integer.parseInt(request.getParameter("pageNow"));
}
%>
<center>
歡迎
<font color=red><%=userName%></font>登入
<br />
<br />軍訓10天會曬得很黑嗎
<br />
<%
UserDao userDao = new UserDao();
int pageNum = userDao.getPageNum();
ArrayList<UserBean> list = userDao.fenyeInfo(pageNow);
int countPage = userDao.getCounPage();
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>
使用者ID
</th>
<th>
使用者名稱
</th>
<th>
密碼
</th>
<th>
使用者類型
</th>
</tr>
<%
for (int i = 0; i < list.size(); i++) {
out.println("<tr><td>" + list.get(i).getUserId() + "</td>");
out.println("<td>" + list.get(i).getUserName() + "</td>");
out.println("<td>" + list.get(i).getPassW() + "</td>");
out.println("<td>" + list.get(i).getGrade() + "</td></tr>");
}
%>
</table>
<!--分頁演算法開始-->
<%
if (pageNow != 1) {
out.println("<a href=manger.jsp?pageNow=" + (pageNow - 1)
+ ">【上一頁】</a>");
}
int start;
if(pageNow < pageNum){
start = 1;
}else{
start = pageNow - 10 + 1;
}
for (int i = start; i <= countPage && i <= pageNow + pageNum; i++) {
if(i == pageNow){
out.println(i);黑眼圈用什麼才可以消掉
continue;
}
out.println("<a href=manger.jsp?pageNow=" + i + ">[" + i
+ "]</a>");
}
if (pageNow != countPage) {
out.println("<a href=manger.jsp?pageNow=" + (pageNow + 1)
+ ">【下一頁】</a>");
}
%>
<!--分頁演算法結束-->
</center>
</body>
</html>