一、系统介绍
1.软件环境
Java:jdk1.8
Mysql:8.0.13
Tomcat:8.5.23
2.系统功能
1.管理员登录系统
2.增加用户信息
3.修改用户信息
3.删除用户信息
4.查询用户信息
3.数据库
/* Navicat Premium Data Transfer Source Server : MySQL Source Server Type : MySQL Source Server Version : 80013 Source Host : localhost:3306 Source Schema : jsp_user_management Target Server Type : MySQL Target Server Version : 80013 File Encoding : 65001 Date: 21/06/2021 22:55:29 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for admin -- ---------------------------- DROP TABLE IF EXISTS `admin`; CREATE TABLE `admin` ( `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of admin -- ---------------------------- INSERT INTO `admin` VALUES ('admin', 'admin'); -- ---------------------------- -- Table structure for userinfo -- ---------------------------- DROP TABLE IF EXISTS `userinfo`; CREATE TABLE `userinfo` ( `userId` int(11) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, `userName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userPwd` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userAge` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userPN` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userJianjie` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userNum` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userPhone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `userTime` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`userId`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of userinfo -- ---------------------------- INSERT INTO `userinfo` VALUES (00000011111, '张三', '111', '26', '第一监狱', '犯人', '0101', '12345678911', '2020-06-01'); INSERT INTO `userinfo` VALUES (00000011112, '张大', '222', '48', '第三监狱', '家属', '0102', '12345678911', '2021-06-01'); INSERT INTO `userinfo` VALUES (00000011113, '李四', '333', '35', '第二监狱', '犯人', '0201', '12345678911', '2021-06-01'); SET FOREIGN_KEY_CHECKS = 1;
二、系统展示
1.登录系统
2.主页面
3.新增用户信息
4.修改用户信息
5.查询用户信息
三、部分代码
DBUtil
package com.sjsq.vo; /** * 管理员类 * @author shuijianshiqing * @date 2021/4/29 22:11 */ public class Admin { // 账号 private String username; // 密码 private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "Admin{" + "username='" + username + '\'' + ", password='" + password + '\'' + '}'; } }
Admin
package com.sjsq.vo; /** * 管理员类 * @author shuijianshiqing * @date 2021/4/29 22:11 */ public class Admin { // 账号 private String username; // 密码 private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "Admin{" + "username='" + username + '\'' + ", password='" + password + '\'' + '}'; } }
AdminDaoImpl
package com.sjsq.dao.impl; import com.sjsq.dao.AdminDao; import com.sjsq.utils.DBUtil; import com.sjsq.vo.Admin; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; /** * @author shuijianshiqing * @date 2021/5/1 9:49 */ public class AdminDaoImpl implements AdminDao { /** * 用户登录 * @param admin * @return */ @Override public Admin login(Admin admin) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // 1.获取数据库连接 con = DBUtil.getConnection(); // 2.写sql String sql = "select * from admin where username = ? and password = ?"; // 3.预编译 ps = con.prepareStatement(sql); // 4.设置值 ps.setObject(1,admin.getUsername()); ps.setObject(2,admin.getPassword()); rs = ps.executeQuery(); Admin adminLogin = null; if(rs.next()){ adminLogin = new Admin(); // 从数据库中获取值到实体类的setter方法中 adminLogin.setUsername(rs.getString("username")); adminLogin.setPassword(rs.getString("password")); // 返回的是你查询出来的完整的对象 return adminLogin; } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); }finally { // 关闭资源,避免出现异常 DBUtil.close(con,ps,rs); } return null; } }
login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> <% // 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错 String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="<%=basePath %>" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>用户登录</title> <style type="text/css"> h1{ text-align: center; } h4{ text-align: center;color: red; } body{ background-color: powderblue; } a{ text-decoration: none;font-size: 20px;color: black; } a:hover{ text-decoration: underline;font-size: 24px;color: red; } </style> </head> <body> <form action="check-login.jsp" method="post"> <h1>用户登录</h1> <hr/> <table align="center"> <tr> <td>账号:</td> <td><input type="text" name="username" placeholder="请输入您的账号" autofocus="autofocus"></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" placeholder="请输入您的密码"></td> </tr> <tr> <td colspan="1"> </td> <td> <input type="submit" value="登录"/> <input type="reset" value="重置"/> </td> </tr> </table> </form> </body> </html>
fail.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>登录失败</title> <style type="text/css"> h1{ text-align: center; } h4{ text-align: center;color: red; } body{ background-color: antiquewhite; } div{ text-align: center; } </style> </head> <body> <h1>用户登录</h1> <hr/> <h4>登录失败</h4> <div> <a href="login.jsp">返回登录</a> </div> </body> </html>
error.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>操作失败</title> <style type="text/css"> body{ text-align: center; } h1{ } #before{ text-align: center; } </style> </head> <body> <h1>操作失败</h1> 操作出错,请回到上一个页面! <div id="before"> <a href="javascript: window.history.go(-1)">返回上一级</a> </div> </br> </body> </html>
add-user.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>新增用户</title> <style type="text/css"> h1{ text-align: center; } body{ background-color: powderblue; } div{ text-align: center; } #before{ text-align: center; } </style> </head> <body> <%-- 头部 --%> <jsp:include page="top.jsp"/> <h1>新增用户</h1> <hr/> <div id="before"> <a href="javascript: window.history.go(-1)">返回上一级</a> </div> </br> <form action="do-add-user.jsp" method="post" name="addForm"> <div> <tr> <label>用户编号:</label> <input type="text" name="userId" id="userId" placeholder="用户编号" autofocus="autofocus"> </tr> </div> <div> <tr> <label>用户姓名:</label> <input type="text" name="userName" id="userName" placeholder="用户姓名" autofocus="autofocus"> </tr> </div> <div> <tr> <label>用户密码:</label></td> <input type="text" name="userPwd" id="userPwd" placeholder="用户密码"> </tr> </div> <div> <tr> <label>用户年龄:</label> <input type="text" name="userAge" id="userAge" placeholder="用户年龄"> </tr> </div> <div> <tr> <label>监狱号码:</label> <input type="text" name="userPN" id="userPN" placeholder="监狱号码"> </tr> </div> <div> <tr> <label>用户简介:</label> <input type="text" name="userJianjie" id="userJianjie" placeholder="用户简介"> </tr> </div> <div> <tr> <label>用户号码:</label> <input type="text" name="userNum" id="userNum" placeholder="用户号码"> </tr> </div> <div> <tr> <label>用户电话:</label> <input type="text" name="userPhone" id="userPhone" placeholder="用户电话"> </tr> </div> <div> <tr> <label>创建时间:</label> <input type="text" name="userTime" id="userTime" placeholder="创建时间"> </tr> </div> <br> <div id="submit"> <tr> <button type="submit" onclick="return checkForm()">添加</button> <button type="reset">重置</button> </tr> </div> </form> <script type="text/javascript"> function checkForm() { var userId = addForm.userId.value; var userName = addForm.userName.value; // 用户名不能为空 if (userId == "" || userId == null) { alert("请输入用户编号"); addForm.userId.focus(); return false; } else if (userName == "" || userName == null) { alert("请输入姓名"); addForm.userName.focus(); return false; } alert('添加成功!'); return true; } </script> <%-- 底部 --%> <jsp:include page="bottom.jsp"/> </body> </html>
四、其他
1.其他系统实现
JavaWeb系统系列实现
Java+JSP实现学生图书管理系统
Java+JSP实现学生信息管理系统
Java+Servlet+JSP实现学生成绩管理系统
Java+Servlet+JSP实现宠物诊所管理系统
Java+SSM+Easyui实现网上考试系统
Java+Springboot+H-ui实现营销管理系统
Java+Springboot+Mybatis+Bootstrap实现网上商城系统
JavaSwing系统系列实现
Java+Swing实现斗地主游戏
Java+Swing实现图书管理系统
Java+Swing实现医院管理系统
Java+Swing实现仓库管理系统
Java+Swing实现考试管理系统
Java+Swing实现通讯录管理系统
Java+Swing实现停车场管理系统
Java+Swing实现学生信息管理系统
Java+Swing实现学生宿舍管理系统
Java+Swing实现学生选课管理系统
Java+Swing实现学生成绩管理系统
Java+Swing实现学校教材管理系统
Java+Swing实现学校教务管理系统
Java+Swing实现企业人事管理系统
Java+Swing实现电子相册管理系统
Java+Swing实现自助取款机(ATM)系统
Java+Swing实现超市管理系统-TXT存储信息
Java+Swing实现宠物商店管理系统-TXT存储信息