⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usermanager1.jsp

📁 系统包含求职用户和系统管理员两个角色
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.publish.jxc.charpter9.*" %>
<jsp:useBean id="xmlBean" class="com.publish.jxc.charpter9.UserXMLAction" scope="request" />
<%//刷新和权限问题
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0);	
	String contextPath = request.getContextPath();
	if (session.getAttribute("user") == null)	{
		out.print(Utility.outPrintPage("你还没登录,无权查看此页面!", contextPath + "/index.jsp"));
		return;
	}
%>
<%
	String strOperation="show";
	String strAct = (String)request.getParameter("act");
	String strId = "";
	if (strAct!=null) {
		String filename = request.getRealPath("/") + "data\\users.xml";
		if (strAct.equals("modiDo")) {  //修改记录
			String strRoles = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("roles").trim()));
			String strTrueName = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("truename").trim()));
			String modiId = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("recordId").trim()));
			if(strTrueName==null || strTrueName.equals("")){
				out.print(Utility.outPrintPage("用户实名不能为空!"));
				return;
			}
			xmlBean.modifyUserInfo(filename, modiId, strTrueName, strRoles);
			session.setAttribute("showList", xmlBean.getArray());
			response.sendRedirect(request.getRequestURI());
			return;
		}
		if (strAct.equals("addnewDo")) {  //新增记录
			String strName = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("name").trim()));
			String strPassword = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("password").trim()));
			String strRoles = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("roles").trim()));
			String strTrueName = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("truename").trim()));
			if(strName==null || strName.equals("")
				|| strTrueName==null || strTrueName.equals("")
				|| strPassword==null || strPassword.equals("")
				|| strRoles==null || strRoles.equals("")) {
				out.print(Utility.outPrintPage("输入的用户信息有错,请核实!"));
				return;
			}
			xmlBean.addUser(filename, strName, strPassword, strTrueName, strRoles);
			session.setAttribute("showList", xmlBean.getArray());
			response.sendRedirect(request.getRequestURI());
			return;
		}
		if (strAct.equals("del")) {  //删除记录
			String delId = Utility.toHTMLString(Utility.UnicodeToChinese((String)request.getParameter("recordId").trim()));
			if (delId==null || delId.equals(""))
			{
				out.print(Utility.outPrintPage("选择要删除的记录!"));
				return;
			}
			//to do
			xmlBean.deleteUser(filename, delId);
			session.setAttribute("showList", xmlBean.getArray());
			response.sendRedirect(request.getRequestURI());
			return;
		}
	}
	if (strAct==null){
		strOperation="show";
	}else{
		if (strAct.equals("modi")){
			strOperation = "modi";
			strId = request.getParameter("recordId");
	}else{
			if(strAct.equals("addnew")){
				strOperation="addnew";
			}else{
				strOperation="show";
			}
		}
	}
%>
<html>
<head>
<title>个人求职管理系统</title>
<link rel="stylesheet" href="<%=contextPath%>/css/itsp.css" type="text/css">
<SCRIPT LANGUAGE=javascript>
function checkform2()
{
	var Checkblank = /^(\s*|(\ )|(\.))*$/;
 	var Checkpassword = /^[0-9a-zA-Z_-]+$/;
 	if (Checkblank.test(dataform2.name.value))	
 	{
 		alert("用户名称不能为空!");
       	dataform2.name.focus();
	  	return false;	
	}  
  	if (Checkblank.test(dataform2.truename.value))
	{
		alert("用户实名不能为空!");
       	dataform2.truename.focus();
	  	return false;	
	} 
	if (Checkblank.test(dataform2.password.value))	 	 
	{
       	alert("用户密码不能为空!");
        dataform2.password.focus();
	  	return false;	
    }
    if (!Checkpassword.test(dataform2.password.value))	 	 
	{
    	alert("用户密码只能有26个英文字母和0~9个数字组成!");
       	dataform2.password.focus();
	  	return false;	
	}
         
	if(dataform2.password.value.length < 6)
	{
  		alert("用户密码不能少于6位!");
 		dataform2.password.focus();
 		return false;	
 	}         
 	window.dataform2.submit();
}
function checkform()
{  	
  	var Checkblank = /^(\s*|(\ )|(\.))*$/;
  	if (Checkblank.test(dataform.truename.value))
  	{
  		alert("用户实名不能为空!");
  		dataform.truename.focus();
  	  	return false;	
  	}  
  	window.dataform.submit();
}
</SCRIPT>
</head>
<body >
<div align="center">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="22">
    <tr> 
      <td width="1"><img src="<%=contextPath%>/images/top_r1.GIF" width="62" height="22"></td>
      <td width=150 align="center"> 个人求职管理系统--用户管理</td>
      <td><img src="<%=contextPath%>/images/top_r2.GIF" width="294" height="22"></td>
	  <td width=100 align="center"><a href="<%=contextPath%>/index.jsp">[ 退出系统 ]</a></td>
    </tr>
  </table>
  <br>
  <br>
  <table bgcolor="#999999" align=center border=0 cellpadding=1 cellspacing=1 
width="90%">
    <tbody> 
    <tr bgcolor="#efefef" align="center" valign="middle"> 
      <td class=ttTable height=30 width="20">&nbsp;</td>
      <td class=ttTable height=30 width="0">用户名称</td>
      <td class=ttTable height=30 width="0">用户密码</td>
      <td class=ttTable height=30 width="0">用户实名</td>
      <td class=ttTable height=30 width="0"> 
        <div align="center">用户等级</div>
      </td>
      <td class=ttTable height=30 width="30"> 
        <div align="center">修改</div>
      </td>
      <td class=ttTable height=30 width="30"> 
        <div align="center">删除</div>
      </td>
    </tr>
<%
	ArrayList userList = (ArrayList)session.getAttribute("showList");
	if (userList != null)
	{
		int length = userList.size();
		for(int i=0; i<length; i++)
		{
			UserXMLModel user = (UserXMLModel)userList.get(i);
			if (strOperation.equals("modi") && strId.equals(user.getId()))
			{
%>
    <!--显示修改的格式-->  
	<tr align="center" bgcolor="#ffffff" valign="middle"> 
      <form name=dataform action="<%=request.getRequestURI()%>?act=modiDo" method="post"  onSubmit='return checkform(this);' >
        <td class=tdsmall height=25 width="20"> 
          <input type="hidden" name="recordId" value="<%=user.getId()%>">
          <%=(i+1)%></td>
        <td class=tdsmall height=25 width="0"><%=user.getName()%></td>
        <!--td class=tdsmall height=25><input name="name" class=stedit style="HEIGHT: 22px; WIDTH: 150px" value="getName()" maxlength="10" ></td-->
        <td class=tdsmall height=25>&nbsp; </td>
        <td class=tdsmall height=25>
          <input name="truename" class=stedit style="HEIGHT: 22px; WIDTH: 150px" value="<%=user.getTrueName()%>" maxlength="10" >
        </td>
        <td class=tdsmall height=25> 
          <select name="roles" class=stedit>
            <option value="user" <% if(user.getRoles().equals("user")){out.print("selected");}%>>用户</option>
            <option value="admin" <% if(user.getRoles().equals("admin")){out.print("selected");}%>>管理员</option>
          </select>
        </td>
        <td class=tdsmall height=25 width="25"><a href="javascript:if (checkform()==false);"><img border=0 
      height=15 src="<%=contextPath%>/images/editok.gif" width=15></a></td>
        <td class=tdsmall height=25 width="25">&nbsp;</td>
        <input name="actionName" type="hidden" value="YHGLMODI">
      </form>
    </tr>
    <% }else{ 
    //显示正常的格式 %>
    <tr align="center" bgcolor="#ffffff" valign="middle"> 
      <td class=tdsmall height=25 width="20"><%=(i+1)%></td>
      <td class=tdsmall height=25 width="0"><%=user.getName()%></td>
      <td class=tdsmall height=25 width="0"><%="******"%></td>
      <td class=tdsmall height=25 width="0"><%=user.getTrueName()%></td>
      <td class=tdsmall height=25 width="0"> <%=user.getRoles()%> 
      </td>
      <td class=tdsmall height=25 width="30"><a href="<%=request.getRequestURI()%>?act=modi&recordId=<%=user.getId()%>"><img border=0 
      		height=15 src="<%=contextPath%>/images/edit.gif" width=15></a></td>
      <td class=tdsmall height=25 width="30"><img border=0 
      		height=15 
      		onClick="javascript:if(confirm('您是否确定删除本记录,删除后将导至记录无法使用?')){window.location.href='<%=request.getRequestURI()%>?act=del&recordId=<%=user.getId()%>';}" 
      		src="<%=contextPath%>/images/delete.gif" style="CURSOR: hand" width=15> </td>
    </tr>
   <%
	    	 } 
		}
	}
%>
<% if (strOperation.equals("addnew")){
    //显示新增的格式%>
    <tr align="center" bgcolor="#ffffff" valign="middle"> 
      <form name=dataform2 action="<%=request.getRequestURI()%>?act=addnewDo" method="post"  onSubmit='return checkform2(this);' >
        <td class=tdsmall height=25 width="20"></td>
        <td class=tdsmall height=25> 
          <input name="name" class=stedit
                  style="HEIGHT: 22px; WIDTH: 150px" value="" maxlength="10" >
        </td>
        <td class=tdsmall height=25> 
          <input name="password" class=stedit type="password"
                  style="HEIGHT: 22px; WIDTH: 100px" value="" maxlength="12" >
        </td>
        <td class=tdsmall height=25>
          <input name="truename" class=stedit
                  style="HEIGHT: 22px; WIDTH: 150px" value="" maxlength="10" >
        </td>
        <td class=tdsmall height=25> 
          <select name="roles" class=stedit>
            <option value="user">用户</option>
            <option value="admin">管理员</option>
          </select>
        </td>
        <td class=tdsmall height=25 width="25"><a href="javascript:if (checkform2()==false);"><img border=0 
      height=15 src="../../images/editok.gif" width=15></a></td>
        <td class=tdsmall height=25 width="25">&nbsp;</td>
      </form>
    </tr>
<%
    } 
	out.print("</tbody></table>"); 
	out.print(Utility.getUserManagerPageSection(strOperation, contextPath, request.getRequestURI()));
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -