jsp网上购物系统代码
展开全部
看懂这个,就OK了,实现会员管理界面(会员查询,删除)
呵呵,注意下面两点,我标志的
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="java.sql.*"%>
<%@ page import="Bean.QueryBean"%>
<jsp:useBean id="query" scope="page" class="Bean.QueryBean"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
admincontrol
</title>
</head>
<%!
ResultSet rs=null;
String sql,login;
int code;
int pagesize=3;
int rowcount=0;
int pagecount=1,n;
int showpage=1;
%>
<script language="javascript">
function check_delete()
{if (confirm("你确定它删除吗?"))
return true;
else
return false;}
</script>
<body bgcolor="#ffffff">
<a href="index.jsp">返回首页<a>
<table border="1" width="786" align="center"bordercolor="#FFFFFF" cellpadding="0" cellspacing="0"bordercolordark="#333333" bordercolorlight="#FFFFFF">
<tr>
<td width="786" align="center" colspan="6" height="32">用户管理</td>
</tr>
<form name="form1" method="post" action="">
<tr>
<td width="18%" align="center"height="27">用户ID</td>
<td width="17%" align="center"height="27">用户名</td>
<td width="17%" align="center"height="27">用户身份</td>
<td width="17%" align="center"height="27">注册时间</td>
<td width="17%" align="center"height="27">管理</td>
</tr>
<%
sql="select * from userinfo order by addtime desc";//会员查询
try
{
rs=query.executeQuery(sql);
if(!rs.next())
{
%>
<script language="javascript">
alert("没有用户信息");
</script>
<%
}else
{
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);
for(int i=1;i<=pagesize;i++)
{
code=rs.getInt("id");
%>
<tr>
<td width="17%" align="center" height="27"><%=code%></td>
<td width="17%" align="center"height="27"><%=rs.getString("username")%></td>
<td width="17%" align="center"height="27"><%=rs.getString("logrole")%></td>
<td width="18%" align="center"height="27"><%=rs.getString("addtime")%></td>
<td width="17%" align="center"height="27"><a href="Userdel?id=<%=code%>" onclick="return check_delete();">删除</a> </td>
</tr>//删除功能
<%
if(!rs.next())
break;
}}
}catch(Exception e)
{out.println("查询异常!!!");}
%>
<tr>
<td width="786" height="30" colspan="9" align="right">
<table width="786" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="786" height="30" colspan="6" align="right">
<div align="center">共<%=pagecount%>页
<a href="admincontrol.jsp?topage=<%=1%>">第一页</a>
<a href="admincontrol.jsp?topage=<%=showpage-1%>">上一页</a>
<a href="admincontrol.jsp?topage=<%=showpage+1%>">下一页</a>
<a href="admincontrol.jsp?topage=<%=pagecount%>">最后一页</a>
</div>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
希望对你能有所帮助。
呵呵,注意下面两点,我标志的
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="java.sql.*"%>
<%@ page import="Bean.QueryBean"%>
<jsp:useBean id="query" scope="page" class="Bean.QueryBean"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
admincontrol
</title>
</head>
<%!
ResultSet rs=null;
String sql,login;
int code;
int pagesize=3;
int rowcount=0;
int pagecount=1,n;
int showpage=1;
%>
<script language="javascript">
function check_delete()
{if (confirm("你确定它删除吗?"))
return true;
else
return false;}
</script>
<body bgcolor="#ffffff">
<a href="index.jsp">返回首页<a>
<table border="1" width="786" align="center"bordercolor="#FFFFFF" cellpadding="0" cellspacing="0"bordercolordark="#333333" bordercolorlight="#FFFFFF">
<tr>
<td width="786" align="center" colspan="6" height="32">用户管理</td>
</tr>
<form name="form1" method="post" action="">
<tr>
<td width="18%" align="center"height="27">用户ID</td>
<td width="17%" align="center"height="27">用户名</td>
<td width="17%" align="center"height="27">用户身份</td>
<td width="17%" align="center"height="27">注册时间</td>
<td width="17%" align="center"height="27">管理</td>
</tr>
<%
sql="select * from userinfo order by addtime desc";//会员查询
try
{
rs=query.executeQuery(sql);
if(!rs.next())
{
%>
<script language="javascript">
alert("没有用户信息");
</script>
<%
}else
{
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);
for(int i=1;i<=pagesize;i++)
{
code=rs.getInt("id");
%>
<tr>
<td width="17%" align="center" height="27"><%=code%></td>
<td width="17%" align="center"height="27"><%=rs.getString("username")%></td>
<td width="17%" align="center"height="27"><%=rs.getString("logrole")%></td>
<td width="18%" align="center"height="27"><%=rs.getString("addtime")%></td>
<td width="17%" align="center"height="27"><a href="Userdel?id=<%=code%>" onclick="return check_delete();">删除</a> </td>
</tr>//删除功能
<%
if(!rs.next())
break;
}}
}catch(Exception e)
{out.println("查询异常!!!");}
%>
<tr>
<td width="786" height="30" colspan="9" align="right">
<table width="786" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="786" height="30" colspan="6" align="right">
<div align="center">共<%=pagecount%>页
<a href="admincontrol.jsp?topage=<%=1%>">第一页</a>
<a href="admincontrol.jsp?topage=<%=showpage-1%>">上一页</a>
<a href="admincontrol.jsp?topage=<%=showpage+1%>">下一页</a>
<a href="admincontrol.jsp?topage=<%=pagecount%>">最后一页</a>
</div>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</body>
</html>
希望对你能有所帮助。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询