<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="java.sql.*" %>
<jsp:useBean id="connBean" scope="page" class="com.BBS.Beans.connDB"/>
<%
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>江枫工作室欢迎你!</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 bgcolor="#FFC040">
<%
int pagesize=5;//设置每张网页显示5个记录
int showpage=1;//设置欲显示的页数
int rowcount=0;//ResultSet的记录数
int pagecount=0;//ResultSet分页后的总页数
int gopage=0;//接受用户的页数选择
if(session.getAttribute("user")==null){
response.sendRedirect("logion.jsp");
}
out.println("欢迎进入主页面!");
//
Connection conn=Pool.getInstance().getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("Select * from user");
rs.last();
rowcount=rs.getRow();
pagecount =((rowcount%pagesize)==0?(rowcount/pagesize):(rowcount/pagesize)+1);
String topage=request.getParameter("topage");
if(topage!=null){
showpage=Integer.parseInt(topage);
if(showpage>pagecount){
showpage=pagecount;
}else if(showpage<=0){
showpage=1;
}
}
rs.absolute((showpage-1)*pagesize+1);//将指针移动到此 ResultSet 对象的给定行编号。
rs.previous();//将指针移动到此 ResultSet 对象的上一行。
out.println("所有数据显示如下:");
%>
<tr>
<td valign="button">当前第<%=showpage%>页</td>
<td valign="button"> 总共<%=pagecount%>页</td>
</tr>
<table cellspacing="1" cellpadding="1" border="1" bgcolor="#80ffff">
<tr>
<td>ID</td>
<td>用户名</td>
<td>密码</td>
<td>真实姓名</td>
<td>电话</td>
<td>地址</td>
<td>性别</td>
<td>年龄</td>
</tr>
<%
for(int i=0;i<pagesize;i++){
if(rs.next()){
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><%=rs.getString(6)%></td>
<td><%=rs.getString(7)%></td>
<td><%=rs.getInt(8)%></td>
</tr>
<%
}else{
break;
}
}
%>
</table>
<tr>
<%
//out.print(showpage);
if(showpage!=1){
%>
<td width="94" valign="middle" align="center"><a href="main.jsp? topage=<%=showpage-1%>">上一页</td>
<%
}
%>
<%
if(showpage!=pagecount){
%>
<td width="85" height="33" align="right" valign="middle"><a href="main.jsp? topage=<%=1%>">第一页</td>
<td width="95" align="right" valign="middle"><a href="main.jsp? topage=<%=showpage+1%>">下一页</td>
<td width="87" valign="middle" align="center"><a href="main.jsp? topage=<%=pagecount%>">最后一页</td>
<%
}
%>
<td>
<form name="from2" action="main.jsp" method="post">
<div><br>到
<select name="topage" onChange="MM_jumpMenu(self,this,1)">
<%for(gopage=1;gopage<=pagecount;gopage++){
if(gopage==showpage){%>
<option value="main.jsp?topage=<%=gopage%>"selsected><%=gopage%></option>
<%
}else{%>
<option value="main.jsp?topage=<%=gopage%>"><%=gopage%></option>
<%}} %>
</select>
</div>
</form>
</td>
</tr>
<form action="Result.jsp" method="post" >
<table>
<tr>
<td>ID</td>
<td><input type="text" name="id" value=""/></td>
<td>用户名</td>
<td><input type="text" name="username" value=""/></td>
<td>真实姓名</td>
<td><input type="text" name="realname" value=""/></td>
</tr>
<tr>
<td>地址</td>
<td><input type="text" name="address" value=""/></td>
<td>性别</td>
<td><input type="text" name="gender" value=""/></td>
<td>年龄</td>
<td><input type="text" name="age" value=""/></td>
</tr>
</table>
<input type="submit" value="查询"/>
</form>
<form action="delete.jsp" method="post">
<table>
<tr>
<td>请输入你要删除用户的id:</td>
<td><input type="text" name="id" value=""></td>
</tr>
<tr>
<td>请输入你要删除用户的用户名:</td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td>请输入你要删除用户的真实姓名:</td>
<td><input type="text" name="realname" value=""></td>
</tr>
</table>
<input type="submit" value="删除"/>
</form>
<form action="add.jsp" method="post" >
<table>
<tr>
<td>ID</td>
<td><input type="text" name="id" value=""/></td>
<td>用户名</td>
<td><input type="text" name="username" value=""/></td>
<td>密码</td>
<td><input type="text" name="pwd" value=""/></td>
</tr>
<tr>
<td>真实姓名</td>
<td><input type="text" name="realname" value=""/></td>
<td>电话</td>
<td><input type="text" name="phone" value=""/></td>
<td>地址</td>
<td><input type="text" name="address" value=""/></td>
</tr>
<tr>
<td>性别</td>
<td><input type="text" name="gender" value=""/></td>
<td>年龄</td>
<td><input type="text" name="age" value=""/></td>
</tr>
</table>
<input type="submit" value="添加"/>
</form>
<form action="update.jsp" method="post">
<table>
<tr>
<td>请输入你要修改的用户ID</td>
<td><input type="text" name="co_id" value=""/></td>
</tr>
<tr>
<td>修改后的用户名</td>
<td><input type="text" name="username" value=""/></td>
<td>修改后的密码</td>
<td><input type="text" name="pwd" value=""/></td>
<td>修改后的真实姓名</td>
<td><input type="text" name="realname" value=""/></td>
</tr>
<tr>
<td>修改后的电话</td>
<td><input type="text" name="phone" value=""/></td>
<td>修改后的地址</td>
<td><input type="text" name="address" value=""/></td>
<td>修改后的性别</td>
<td><input type="text" name="gender" value=""/></td>
</tr>
<tr>
<td>修改后的年龄</td>
<td><input type="text" name="age" value=""/></td>
</tr>
</table>
<input type="submit" value="修改"/>
</form>
</body>
</html>

你可能感兴趣的:(content)