📄 user.jsp
字号:
<%@ page language="java" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>
<%@page import="com.ideas.util.*,java.util.*"%>
<%
//超时提示
if((String)session.getAttribute("login")==null) {
response.sendRedirect("../session.htm");
}
%>
<jsp:useBean id="myBean" scope="page" class="com.ideas.bean.userBean"/>
<%
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
//设置一页显示的记录数
intPageSize = Configuration.Number_shown;
//取得待显示页码
strPage = request.getParameter("page");
if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
}
else{//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
int recno=(intPage-1)*intPageSize+1;
//DBConnectionManager connMgr=DBConnectionManager.getInstance();
//Connection con = connMgr.getConnection(Configuration.ConnectionPoolName);
//创建数据库连接
if (!myBean.getMyConnPool()) {
out.println("不能获取数据库连接.");
return;
}
//edit
String id1 = (String)request.getParameter("id");
String type1 = (String)request.getParameter("type");
String user1 = (String)request.getParameter("user");
String pwd1 = (String)request.getParameter("pwd");
String info1 = (String)request.getParameter("info");
String islock1 = (String)request.getParameter("islock");
if(info1==null)info1 = "";
info1 = new String(info1.getBytes("ISO-8859-1"),"GBK");
if(type1==null)type1 = "";
int error = 0;
if(type1.equals("1"))
{
Hashtable hash= new Hashtable();
hash.put("user", user1);
hash.put("pwd", pwd1);
hash.put("info", info1);
error = myBean.add(hash);
}
else if(type1.equals("2"))
{
myBean.setID(id1);
Hashtable hash= new Hashtable();
hash.put("user", user1);
hash.put("pwd", pwd1);
hash.put("info", info1);
hash.put("islock", islock1);
error = myBean.mod(hash);
}
else if(type1.equals("3"))
{
myBean.setID(id1);
myBean.del();
}
//取得当前页的数据
Vector vect = myBean.getCurPage(intPage,intPageSize);
//获取记录总数
intRowCount = Integer.parseInt((String)vect.get(0));
//记算总页数
intPageCount = Integer.parseInt((String)vect.get(1));
//调整待显示的页码
if(intPage>intPageCount) intPage = intPageCount;
%>
<html>
<head>
<title>用户管理</title>
<link rel="STYLESHEET" type="text/css" href="../css/yj.css">
</head>
<body>
<center><H1>用户管理</H1></center>
<h2> 第<%=intPage%>页 共<%=intPageCount%>页(<%=intRowCount%>条) <a href="user.jsp?">首页</a> <%if(intPage>1){%><a href="user.jsp?&page=<%=intPage-1%>">上一页</a><%}%> <%if(intPage<intPageCount){%><a href="user.jsp?&page=<%=intPage+1%>">下一页</a><%}%> <a href="user.jsp?&page=<%=intPageCount%>">尾页</a> <a onclick="javascript:window.location.reload();" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';" style="cursor:hand;" ><font color="blue">刷新数据</font></a></h2>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="8%" align="center" >序号</th>
<th width="10%" align="center" >用户名</th>
<th width="10%" align="center" >密码</th>
<th width="10%" align="center" >状态</th>
<th width="*" align="center" >备注</th>
<th width="19%" align="center"><A onclick="add('');" style="cursor:hand;" class="hold1">〖新增〗</A></th>
<tr>
<%
if(intPageCount>0){
for (int line=2;line<vect.size();line++) {
Hashtable hash = (Hashtable)vect.get(line);
String mode=null;
if (line%2==1)
mode="row3";
else
mode="row1";
String id = (String)hash.get("id");
String islock = (String)hash.get("islock");
String t = "锁定";
if(islock.equals("0"))t = "可用";
String user = (String)hash.get("user");
%>
<tr>
<td height=21 align="center" class="<%=mode%>" ><%=recno++%></td>
<td align="center" class="<%=mode%>" ><%=user%></td>
<td align="center" class="<%=mode%>" ><%=hash.get("pwd")%></td>
<td align="center" class="<%=mode%>" ><%=t%></td>
<td align="center" class="<%=mode%>" ><%=hash.get("info")%></td>
<td align="center" class="<%=mode%>">
<%if(!user.equals("admin")){%>
<A onclick="edit('<%=id%>');"style="cursor:hand;" class="hold">『修改』</A>
<A onclick="del('<%=id%>');" style="cursor:hand;" class="hold">『删除』</A><%}%>
</td>
</tr>
<%
}
}//end for%>
</table>
<form name=form1 action="" method=post>
</form>
<%
//connMgr.freeConnection(Configuration.ConnectionPoolName, con);
myBean.releaseMyConnPool();
%>
<script>
function add()
{
document.all.form1.action = "edit.jsp?type=1&page=<%=intPageCount%>";
document.all.form1.submit();
}
function edit(id)
{
document.all.form1.action = "edit.jsp?type=2&id="+id+"&page=<%=intPageCount%>";
document.all.form1.submit();
}
function del(id)
{
if(!confirm("是否真的要删除?"))
{
}
else
{
document.all.form1.action = "user.jsp?type=3&id="+id+"&page=<%=intPageCount%>";
document.all.form1.submit();
}
}
var error="<%=error%>";
if(error!="0")alert("该用户名已经存在!");
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -