基于javaweb+jsp的访客管理系统
2021/12/4 1:17:39
本文主要是介绍基于javaweb+jsp的访客管理系统,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
基于javaweb+jsp的访客管理系统
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架…均可
开发工具:idea或eclipse或myeclipse
部分代码实现JSP
let id = button.data('id'); let modal = $(this); $.ajax({ url: 'LaifangServlet?action=get&id=' + id, type: "get", success: function (voString) { let vo = eval('(' + voString + ')'); modal.find('#edit-id').val(vo.id); modal.find('#edit-laifangName').val(vo.laifangName); for (let val of "男/女".split('/')) { if (val == vo.laifangSex) { modal.find('#edit-laifangSex_' + vo.laifangSex).prop("checked", true); } else {
<input class="form-control" type="text" id="search_keyword" name="search_keyword" placeholder="姓名"/> <span class="input-group-btn"><button class="btn btn-line btn-primary" type="button" onclick="searchList()">搜索</button></span> </div> </div> <div class="col-sm-5"> <button type="button" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> class="btn btn-line btn-default" data-toggle="modal" data-target="#modal-add">添加来访 </button> </div> </div> <br> <br> <div class="table-responsive"> <table class="table table-striped table-hover"> <thead> <tr> <th>姓名</th> <th>性别</th> <th>身份证</th> <th>电话</th> <th>来访时间</th>
</div> </div> <div class="modal-footer"> <button type="button" class="btn btn-line btn-warning" data-dismiss="modal">取消</button> <button type="submit" class="btn btn-line btn-primary">删除</button> </div> </form> </div> </div> </div> </body> <script> $('#modal-delete').on('show.bs.modal', function (event) { let button = $(event.relatedTarget); let id = button.data('id'); let modal = $(this); modal.find('#delete-id').val(id); }) $('#modal-edit').on('show.bs.modal', function (event) {
<input name="laifangSex" id="add-laifangSex_男" type="radio" value="男" checked="checked"/>男 <input name="laifangSex" id="add-laifangSex_女" type="radio" value="女"/>女 </div> <div class="form-group"> <label for="add-laifangIdno" class="control-label">身份证:</label> <input type="text" class="form-control" name="laifangIdno" id="add-laifangIdno"> </div> <div class="form-group"> <label for="add-laifangPhone" class="control-label">电话:</label> <input type="text" class="form-control" name="laifangPhone" id="add-laifangPhone"> </div> <div class="form-group"> <label for="add-laifangIndate" class="control-label">来访时间:</label> <input type="text" class="form-control" name="laifangIndate" id="add-laifangIndate"> </div> <div class="form-group"> <label for="add-laifangOutdate" class="control-label">离开时间:</label> <input type="text" class="form-control" name="laifangOutdate" id="add-laifangOutdate"> </div>
</div> <!-- edit --> <div class="modal fade" id="modal-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <form action="LaifangServlet" onsubmit="return editCheck()"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">更新来访</h4> </div> <div class="modal-body">
<tr> <td style="width: 15%;">身份证:</td> <td><b id="info-laifangIdno"></b></td> </tr> <tr> <td style="width: 15%;">电话:</td> <td><b id="info-laifangPhone"></b></td> </tr> <tr> <td style="width: 15%;">来访时间:</td> <td><b id="info-laifangIndate"></b></td> </tr> <tr> <td style="width: 15%;">离开时间:</td>
return true; } </script>
</tr> <tr> <td style="width: 15%;">事由:</td> <td><b id="info-laifangReason"></b></td> </tr> <tr> <td style="width: 15%;">备注:</td> <td><b id="info-laifangText"></b></td> </tr> </table> <br> </div> <div class="modal-footer"> <button type="button" class="btn btn-line btn-warning" data-dismiss="modal">关闭</button> </div> </form> </div>
modal.find('#info-laifangSex').text(vo.laifangSex); modal.find('#info-laifangIdno').text(vo.laifangIdno); modal.find('#info-laifangPhone').text(vo.laifangPhone); modal.find('#info-laifangIndate').text(vo.laifangIndate); modal.find('#info-laifangOutdate').text(vo.laifangOutdate); modal.find('#info-laifangReason').text(vo.laifangReason); modal.find('#info-laifangText').text(vo.laifangText); } }) }) function searchList() { window.location.href = "LaifangServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value; } //增加表单提交之前进行检查,如果return false,则不允许提交 function addCheck() { //根据ID获取值 if (document.getElementById("add-laifangName").value.trim().length == 0) {
<!-- delete --> <div class="modal fade" id="modal-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <form action="LaifangServlet"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">删除来访</h4> </div> <div class="modal-body"> 确认要删除该来访记录吗? <div class="form-group hidden"> <label class="control-label">(hidden)</label> <input type="hidden" class="form-control" name="action" value="delete">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">访客管理系统</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">访客管理系统</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <li><a href="#">欢迎:<span style="color: yellow">${loginUser.username}</span></a></li> <li><a href="AuthServlet?action=logout">退出</a></li> </ul> </div> </div> </nav>
<textarea style="height: 100px;" class="form-control" name="laifangText" id="edit-laifangText"></textarea> </div> <div class="form-group hidden"> <label for="edit-createTime" class="control-label">创建时间:</label> <input type="text" class="form-control" name="createTime" id="edit-createTime"> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-line btn-warning" data-dismiss="modal">取消</button> <button type="submit" class="btn btn-line btn-default">提交</button> </div> </form> </div> </div>
return false; } if (document.getElementById("add-laifangIdno").value.trim().length == 0) { alert("身份证不能为空"); return false; } if (document.getElementById("add-laifangPhone").value.trim().length == 0) { alert("电话不能为空"); return false; } if (document.getElementById("add-laifangIndate").value.trim().length == 0) { alert("来访时间不能为空"); return false; } if (document.getElementById("add-laifangOutdate").value.trim().length == 0) {
<div class="modal fade" id="modal-info" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <form> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">来访</h4> </div> <div class="modal-body"> <table class="table table-striped table-hover" style="font-size: 15px;"> <tr> <td style="width: 15%;">姓名:</td> <td><b id="info-laifangName"></b></td> </tr> <tr> <td style="width: 15%;">性别:</td> <td><b id="info-laifangSex"></b></td>
<label class="control-label">(hidden)</label> <input type="text" class="form-control" name="action" value="edit"> <input type="text" readonly class="form-control" name="id" id="edit-id"> </div> <div class="form-group"> <label for="edit-laifangName" class="control-label">姓名:</label> <input type="text" class="form-control" name="laifangName" id="edit-laifangName"> </div> <div class="form-group"> <label class="control-label">性别:</label> <input name="laifangSex" id="edit-laifangSex_男" type="radio" value="男"/>男 <input name="laifangSex" id="edit-laifangSex_女" type="radio" value="女"/>女 </div> <div class="form-group"> <label for="edit-laifangIdno" class="control-label">身份证:</label> <input type="text" class="form-control" name="laifangIdno" id="edit-laifangIdno"> </div>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>来访管理</title> <link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/main.css"> <script src="js/jquery-3.5.1.js"></script> <script src="js/bootstrap.js"></script> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid">
} }; modal.find('#edit-laifangIdno').val(vo.laifangIdno); modal.find('#edit-laifangPhone').val(vo.laifangPhone); modal.find('#edit-laifangIndate').val(vo.laifangIndate); modal.find('#edit-laifangOutdate').val(vo.laifangOutdate); modal.find('#edit-laifangReason').val(vo.laifangReason); modal.find('#edit-laifangText').val(vo.laifangText); } }) }) $('#modal-info').on('show.bs.modal', function (event) { let button = $(event.relatedTarget); let id = button.data('id'); let modal = $(this); $.ajax({ url: 'LaifangServlet?action=get&id=' + id, type: "get", success: function (voString) { let vo = eval('(' + voString + ')');
<label for="edit-laifangPhone" class="control-label">电话:</label> <input type="text" class="form-control" name="laifangPhone" id="edit-laifangPhone"> </div> <div class="form-group"> <label for="edit-laifangIndate" class="control-label">来访时间:</label> <input type="text" class="form-control" name="laifangIndate" id="edit-laifangIndate"> </div> <div class="form-group"> <label for="edit-laifangOutdate" class="control-label">离开时间:</label> <input type="text" class="form-control" name="laifangOutdate" id="edit-laifangOutdate"> </div> <div class="form-group"> <label for="edit-laifangReason" class="control-label">事由:</label> <input type="text" class="form-control" name="laifangReason" id="edit-laifangReason"> </div> <div class="form-group">
<label for="add-laifangReason" class="control-label">事由:</label> <input type="text" class="form-control" name="laifangReason" id="add-laifangReason"> </div> <div class="form-group"> <label for="add-laifangText" class="control-label">备注:</label> <textarea style="height: 100px;" class="form-control" name="laifangText" id="add-laifangText"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-line btn-warning" data-dismiss="modal">取消</button> <button type="submit" class="btn btn-line btn-default">提交</button> </div> </form> </div> </div> </div>
} if (document.getElementById("edit-laifangPhone").value.trim().length == 0) { alert("电话不能为空"); return false; } if (document.getElementById("edit-laifangIndate").value.trim().length == 0) { alert("来访时间不能为空"); return false; } if (document.getElementById("edit-laifangOutdate").value.trim().length == 0) { alert("离开时间不能为空"); return false; } if (document.getElementById("edit-laifangReason").value.trim().length == 0) { alert("事由不能为空"); return false;
<div class="row"> <div class="col-sm-3 col-md-2 sidebar"> <!-- 侧边栏 --> <jsp:include page="menu.jsp"> <jsp:param value="active" name="Laifang_active"/> </jsp:include> </div> <br> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <div class="row"> <div class="col-sm-7"> <div class="input-group">
<th>事由</th> <th style="text-align: center;">操作</th> </tr> </thead> <tbody> <c:forEach items="${list}" var="vo"> <tr> <td>${vo.laifangName}</td> <td>${vo.laifangSex}</td> <td>${vo.laifangIdno}</td> <td>${vo.laifangPhone}</td> <td>${vo.laifangIndate}</td> <td>${vo.laifangOutdate}</td> <td>${vo.laifangReason}</td> <th style="text-align: center;"> <button class="btn btn-line btn-warning btn-sm" data-id="${vo.id}" data-toggle="modal" data-target="#modal-info">详情 </button> <button class="btn btn-line btn-primary btn-sm"
return false; } if (document.getElementById("add-laifangReason").value.trim().length == 0) { alert("事由不能为空"); return false; } return true; } //编辑表单提交之前进行检查,如果return false,则不允许提交 function editCheck() { //根据ID获取值 if (document.getElementById("edit-laifangName").value.trim().length == 0) { alert("姓名不能为空"); return false; } if (document.getElementById("edit-laifangIdno").value.trim().length == 0) { alert("身份证不能为空");
data-id="${vo.id}" data-toggle="modal" data-target="#modal-edit">编辑 </button> <button class="btn btn-line btn-primary btn-sm" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> data-id="${vo.id}" data-toggle="modal" data-target="#modal-delete">删除 </button> </th> </tr> </c:forEach> </tbody> </table> </div> <div style="float: right;padding-right: 10px;color: #515151;"><jsp:include page="split.jsp"/></div> </div> </div> </div> <!-- add -->
aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <form action="LaifangServlet" onsubmit="return addCheck()"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title" id="myModalLabel">增加来访</h4> </div> <div class="modal-body"> <div class="form-group hidden"> <label class="control-label">(hidden)</label> <input type="text" class="form-control" name="action" value="add"> </div> <div class="form-group"> <label for="add-laifangName" class="control-label">姓名:</label> <input type="text" class="form-control" name="laifangName" id="add-laifangName"> </div> <div class="form-group">
Java代码:略
运行环境
Java≥6、Tomcat≥7.0、MySQL≥5.5
开发工具
idea/eclipse/MyEclipse
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架…均可
开发工具:idea或eclipse或myeclipse
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、来访模块的增删改查管理
这篇关于基于javaweb+jsp的访客管理系统的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南