Javaweb学生信息管理系统(Mysql+JSP+MVC+CSS)

news/2023/10/4 2:14:11

目录

一.项目介绍

二.运行效果

1.登录界面

2.主界面(点击学号修改学生信息)

3.增加学生界面

?编辑

三.项目目录结构

?四.代码展示

1.jsp及css代码

?①登录界面代码(login.jsp)

②登录界面css(login.css)

③注册用户界面(register.jsp)

④注册用户界面css(index.css)

⑤修改密码界面(UpdateLoginID.jsp)

⑥注销用户界面(DeleteLoginID.jsp)

⑦登录成功主界面(index.jsp)

⑧登陆成功界面css(show.css)

⑨点击学号,修改学生信息界面(StudentInfo.jsp)

⑩增加学生信息(add.jsp)

?上传作业操作(UpAndDown.jsp)

2.三层架构

①表示层Servlet

②业务逻辑层Service

③数据访问层Dao

④通用的数据库操作(DBUtils.java)

3.JavaBean封装数据

①分页帮助类(Page.java)

②封装学生信息(Student.java)

4.项目所需jar包

五.数据库表格

①登录注册表格login

②学生信息表格student1


一.项目介绍

本系统主要实现对基于Javaweb学生信息管理系统所需的各项基本功能,能够对学生信息进行增删改查等功能,并可以实现用户注册、用户登陆等功能。

数据库:Mysql

开发工具:Eclipse

开发环境:JDK+Tomcat

二.运行效果

1.登录界面

2.主界面(点击学号修改学生信息)

3.增加学生界面

三.项目目录结构

四.代码展示

1.jsp及css代码

①登录界面代码(login.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link href="css/login.css" type="text/css" rel="stylesheet">
<meta charset="UTF-8"><title>学生信息管理系统-登录界面</title>
</head>
<body><form action="CheckLoginServlet" method="post"><div class="content"><div class="wrap"><div class="login-box"><div class="login-frame"><h2>用户登录 <a href="register.jsp"> 立即注册</a></h2><div class=item><input type="text" name="UID" placeholder="用户名"></div><div class=item><input type="password" name="upwd" placeholder="密码"></div><input type="submit" class="login-btn" value="登 录"><div class=item1><a href="UpdateLoginPwd.jsp"> 修改密码</a> <a	href="DeleteLoginID.jsp"> 注销用户</a></div><%String error = (String) request.getAttribute("error");String error0 = (String) request.getAttribute("error0");String error1 = (String) request.getAttribute("error1");String error2 = (String) request.getAttribute("error2");String error3 = (String) request.getAttribute("error3");String error4 = (String) request.getAttribute("error4");if (error != null) {if (error.equals("loginError")) {out.println("用户名或密码错误!登录失败!");} else if (error.equals("nologinError")) {response.sendRedirect("QueryStudentByPageServlet");}}if (error0 != null) {if (error0.equals("loginError")) {out.println("用户名或密码错误!修改失败!");} else if (error0.equals("nologinError")) {if (error1 != null) {if (error1.equals("noupdateError")) {out.println("密码修改成功!");}}}}if (error2 != null) {if (error2.equals("loginError")) {out.println("用户名或密码错误!注销失败!");} else if (error2.equals("nologinError")) {if (error3 != null) {if (error3.equals("nodeleteError")) {out.println("账户注销成功!");}}}}if (error4 != null) {if (error4.equals("noaddError")) {out.println("账户注册成功!");}}%></div></div></div></div></form></body></html>

②登录界面css(login.css)

*{margin:0;padding:0;}
a{text-decoration:none;color:#666;}
a:hover{text-decoration:underline;color:E4393C;
}
html,body
{font:12px/150% Arial,Verdana;
}.wrap{width:1000px;margin:0 auto;
}
.left{float:left;
}.content{background:url(../image/login.jpg);background-size: cover;width:1280px;height:559px;
}.login-frame{margin:50px 5% 50px 5%;float:right;padding:60px;background:white;background-color:rgba(255,255,255,0.9);border-radius:25px;order-right:1px #bdbdbd solid;width:280px;height:230px;
}.login-frame h2{font-size:25px;height:40px;margin-buttom:25px;
}
.login-frame h2 a{font-size:15px;color:#59c2c5;padding-left:20px;background:url(../image/icon5.jpg)no-repeat;
}.login-frame .item{height:60px;margin-buttom:40px;
}.login-frame .item input{line-height:40px;width:260px;border:none;border-bottom: 1px solid #59c2c5;
}.login-btn{display:block;height:50px;display:block;height:50px;color:#fff;background:#59c2c5;width:265px;font-size:16px;line-height:30px;text-align:center;border-radius:10px;border:none;color:#fff;background:#59c2c5;width:265px;font-size:16px;line-height:30px;text-align:center;border-radius:10px;border:none;
}
.login-frame .item1{dislpay:flex;justify-content: space-between;margin-top:1 rem;
}
.login-frame .item1 a{line-height:40px;font-size:1.1rem;margin-top:5 rem;padding:1rem 3rem;
}

③注册用户界面(register.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link href="css/index.css" type="text/css" rel="stylesheet">
<meta charset="UTF-8">
<script type = "text/javascript" src = "js/jquery-3.6.0.js"></script><script type = "text/javascript">function check(){var UID = $("#UID").val();var upwd = $("#upwd").val();var upwd1 = $("#upwd1").val();if(upwd != upwd1){alert("两次输入的密码不一致,请重新输入!");return false;}return true;}$(document).ready(function(){});</script>
<title>注册账号</title>
</head>
<body><form action = "AddLoginIDServlet" method = "post" onsubmit = "return check()"><div class = "content"><div class = "box"><div class = "item1"><h2>用户注册</h2></div><div class = "item"><input type = "text" name = "UID" id = "UID" placeholder="账号"/><br/></div><div class = "item"><input type = "password" name = "upwd" id = "upwd" placeholder="密码"/><br/></div><div class = "item"><input type = "password" name = "upwd1" id = "upwd1" placeholder="确认密码"/><br/></div><input type = "submit" class = "btn" value = "注册"/><br/><a href = "login.jsp">返回</a><%String error4 = (String) request.getAttribute("error4");if (error4!= null) {if (error4.equals("addError")) {out.println("注册失败!账户名已经存在!");} }%></div></div></form></body>
</html>

④注册用户界面css(index.css)

*{margin:0;padding:0;}
html,body
{font:12px/150% Arial,Verdana;
}
.content{background:url(../image/login.jpg);background-size: cover;width:1280px;height:559px;
}
.box{margin:60px 18% 60px 18%;float:right;padding:30px;background:white;background-color:rgba(255,255,255,0.9);border-radius:15px;}
.item{height:60px;margin-buttom:40px;
}
.item input{line-height:40px;width:260px;border:none;border-bottom: 1px solid #59c2c5;border-radius:3px;
}
.item1{font-size:15px;height:40px;
}
.btn{display:block;height:50px;color:#fff;background:#59c2c5;width:265px;font-size:16px;line-height:30px;text-align:center;border-radius:10px;border:none;
}

⑤修改密码界面(UpdateLoginID.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link href="css/index.css" type="text/css" rel="stylesheet">
<meta charset="UTF-8"><script type = "text/javascript" src = "js/jquery-3.6.0.js"></script><script type = "text/javascript">function check(){var upwd = $("#upwd").val();var upwd1 = $("#upwd1").val();var upwd2 = $("#upwd2").val();if(upwd1 != upwd2){alert("两次输入的密码不一致,请重新输入!");return false;}return true;}$(document).ready(function(){});</script><title>更改账号密码</title>
</head>
<body><form action = "UpdateLoginPwdServlet" method = "post" onsubmit = "return check()"><div class = "content"><div class = "box"><div class= "item1"><h2>修改密码</h2></div><div class = item><input type = "text" name = "UID" id = "UID" placeholder="账号"/><br/></div><div class = item><input type = "password" name = "upwd" id = "upwd" placeholder="旧密码"/><br/></div><div class = item><input type = "password" name = "upwd1" id = "upwd1" placeholder="新密码"/><br/></div><div class = item><input type = "password" name = "upwd2" id = "upwd2" placeholder="确认密码"/><br/></div><input type = "submit" class = "btn" value = "提交"/><br/><a href = "login.jsp">返回</a><%String error0 = (String) request.getAttribute("error0");if (error0!= null) {if (error0.equals("loginError")) {out.println("用户名或密码错误,请重新输入!");} else if (error0.equals("nologinError")) {response.sendRedirect("login.jsp");}}%></div></div></form>
</body>
</html>

⑥注销用户界面(DeleteLoginID.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link href="css/index.css" type="text/css" rel="stylesheet">
<meta charset="UTF-8">
<title>注销账号</title>
</head>
<body><form action = "DeleteLoginIDServlet" method = "post"><div class = "content"><div class = "box"><div class = "item1"><h2>注销账号</h2></div><div class = "item"><input type = "text" name = "UID" id = "UID" placeholder="账号"/><br/></div><div class = "item"><input type = "password" name = "upwd" id = "upwd" placeholder="密码"/><br/></div><input type = "submit" class = "btn" value = "注销"/><br/><a href = "login.jsp">返回</a><%String error2 = (String) request.getAttribute("error2");if (error2!= null) {if (error2.equals("loginError")) {out.println("用户名或密码错误!注销失败!");}}%></div></div></form>
</body>
</html>

⑦登录成功主界面(index.jsp)

点击学号进入单个学生信息展示界面,可修改学生信息

点击删除删除学生信息

<%@page import="student.entity.Page"%>
<%@page import="java.util.List"%>
<%@page import="student.entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><script type = "text/javascript" src = "js/jquery-3.6.0.js"></script><script type = "text/javascript">$(document).ready(function(){$("tr:odd").css("background-color","lightgrey");});</script><link href="css/show.css" type="text/css" rel="stylesheet">
<meta charset="UTF-8">
<title>学生信息列表</title>
</head>
<body><div class = "content"><div class = "box"><table  border="2" cellspacing="0"><tr><th><h2>学号</h2></th><th><h2>姓名</h2></th><th><h2>年龄</h2></th><th><h2>专业</h2></th><th><h2>操作</h2></th></tr><%Page page1 = (Page)request.getAttribute("page1");for(Student student:page1.getStudents()){%><tr><td><a href = "QueryStudentBySnoServlet?sno=<%=student.getSno()%>"><%=student.getSno() %></a></td><td><%=student.getName() %></td><td><%=student.getAge() %></td><td><%=student.getDept() %></td><td><a href = "DeleteStudentServlet?sno=<%=student.getSno() %>">删除</a></td></tr><%			}%></table><div class = item><a href = "add.jsp">增加学生</a></div><% if(page1.getCurrentPage()==page1.getTotalPage()-1){%><div class = item><a href = "QueryStudentByPageServlet?currentPage=0">首页</a><a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()-1%>">上一页</a></div><% }else if(page1.getCurrentPage()==0){%><div class = item><a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()+1%>">下一页</a><a href = "QueryStudentByPageServlet?currentPage=<%=page1.getTotalPage()-1%>">尾页</a></div><%}else{%><div class = item><a href = "QueryStudentByPageServlet?currentPage=0">首页</a><a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()-1%>">上一页</a><a href = "QueryStudentByPageServlet?currentPage=<%=page1.getCurrentPage()+1%>">下一页</a><a href = "QueryStudentByPageServlet?currentPage=<%=page1.getTotalPage()-1%>">尾页</a></div><%}%><input type = "button" value = "上传作业" class = "btn"  onclick = "location = 'UpAndDown.jsp'"/><br/><%String error = (String)request.getAttribute("error");if(error!=null){if(error.equals("addError")){out.println("增加失败!");}else if(error.equals("noaddError")){out.println("增加成功!");}}String error1 = (String)request.getAttribute("error1");if(error1!=null){if(error1.equals("deleteError")){out.println("删除失败!");}else if(error1.equals("nodeleteError")){out.println("删除成功!");}}String error2 = (String)request.getAttribute("error2");if(error2!=null){if(error2.equals("updateError")){out.println("修改失败!");}else if(error2.equals("noupdateError")){out.println("修改成功!");}}String error3 = (String)request.getAttribute("error3");if(error3!=null){if(error3.equals("uploadError")){out.println("上传失败!");}else if(error3.equals("nouploadError")){out.println("上传成功!");}}%></div></div>
</body>
</html>

⑧登陆成功界面css(show.css)

*{margin:0;padding:0;}
html,body
{font:12px/150% Arial,Verdana;
}
.content{background:url(../image/index.JPG);background-size: cover;width:1280px;height:559px;
}
.box{margin:60px 18% 60px 18%;float:right;padding:30px;background:white;background-color:rgba(255,255,255,0.9);border-radius:15px;}
.item{height:40px;border-radius:15px;
}
.item a{background-color: lightgrey;text-decoration: none;font-size:15px;color:black;border-radius:3px;
}
.item1{font-size:15px;height:40px;
}
table{width:100%;border-collapse:collapse;
}
table body{diaplay:block;height:300px;overflow-y: scroll;
}
table td{border:1px solid #A6A6A6;height:60px;width:300px;text-align: center;font-size: 15px;
}
table th{height:60px;border:1px solid #A6A6A6;
}

⑨点击学号,修改学生信息界面(StudentInfo.jsp)

<%@page import="student.entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="css/index.css" type="text/css" rel="stylesheet">
<title>修改学生信息</title>
</head>
<body><%Student student = (Student)request.getAttribute("student");%>		<form action = "UpdateStudentServlet" method = "post"><div class = "content"><div class = "box"><div class = "item1"><h2>修改学生信息</h2></div><div class = "item">学号:<input type = "text" name = "sno" value ="<%=student.getSno()%>" readonly = "readonly"/><br/></div><div class = "item">姓名:<input type = "text" name = "name" value ="<%=student.getName()%>"/><br/></div><div class = "item">年龄:<input type = "text" name = "age" value ="<%=student.getAge()%>"/><br/></div><div class = "item">专业:<input type = "text" name = "dept" value ="<%=student.getDept()%>"/><br/></div><input type = "submit" class = "btn" value = "修改"/><a href = "QueryStudentByPageServlet">返回</a></div></div></form>
</body>
</html>

⑩增加学生信息(add.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="css/index.css" type="text/css" rel="stylesheet">
<script type = "text/javascript" src = "js/jquery-3.6.0.js"></script><script type = "text/javascript">function check(){var sname = $("#sname").val();var sno = $("#sno").val();var sage = $("#sage").val();var sdept = $("#sdept").val();if(!(sno>1&&sno<2000)){alert("学号有误!必须是1-2000");return false;}if(!(sname.length>1&&sname.length<5)){alert("姓名有误!必须是2-4位");return false;}if(!(sage>1&&sage<100)){alert("年龄有误!必须是1-100");return false;}return true;}$(document).ready(function(){});</script><title>增加学生信息</title>
</head>
<body><form action = "AddStudentServlet" method = "post"  onsubmit = "return check()"><div class = "content"><div class = "box"><div class = "item2"><h2>增加学生信息</h2></div><div class = "item"><input type = "text" name = "name" id = "sname" placeholder="姓名"/><br/></div><div class = "item"><input type = "text" name = "sno" id = "sno" placeholder="学号"/><br/></div><div class = "item"><input type = "text" name = "age" id = "sage" placeholder="年龄"/><br/></div><div class = "item"><input type = "text" name = "dept" id = "sdept" placeholder="专业"/><br/></div><input type = "submit" class = "btn" value = "增加"/><br/><a href = "QueryStudentByPageServlet">返回</a></div></div></form>
</body>
</html>

上传作业操作(UpAndDown.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="css/index.css" type="text/css" rel="stylesheet">
<title>上传作业</title>
</head>
<body><form action ="UploadServlet" method = "post" enctype = "multipart/form-data"><div class = "content"><div class = "box"><div class = "item2"><h2>上传作业</h2></div><div class = "item"><input type = "text" name="sno" placeholder="学号"/><br/></div><div class = "item"><input type = "text" name = "name" placeholder="姓名"/><br/></div><input type = "file" name = "spiature"/><br/><br/><input type = "submit" class = "btn" value ="上传"/><a href = "QueryStudentByPageServlet">返回</a></div></div></form>
</body>
</html>

2.三层架构

①表示层Servlet

检查登录的用户名和密码是否匹配(CheckLoginServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;public class CheckLoginServlet extends HttpServlet {protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");String ID = request.getParameter("UID");String pwd = request.getParameter("upwd");IStudentService service = new StudentServiceImpl();boolean result = service.checkLoginID(ID,pwd);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error", "loginError");}else {request.setAttribute("error", "nologinError");}request.getRequestDispatcher("login.jsp").forward(request, response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

注册账户表示层(AddLoginIDServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;/*** Servlet implementation class AddLoginIDServlet*/
public class AddLoginIDServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");String ID = request.getParameter("UID");String pwd = request.getParameter("upwd");IStudentService studentService = new StudentServiceImpl();boolean result = studentService.addLoginID(ID,pwd);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error4", "addError");request.getRequestDispatcher("register.jsp").forward(request, response);}else {request.setAttribute("error4", "noaddError");request.getRequestDispatcher("login.jsp").forward(request, response);}}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

修改密码表示层(UpdateLoginPwdServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;/*** Servlet implementation class UpdateLoginPwdServlet*/
public class UpdateLoginPwdServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");String ID = request.getParameter("UID");String pwd = request.getParameter("upwd");String pwd1 = request.getParameter("upwd1");IStudentService service = new StudentServiceImpl();boolean result = service.checkLoginID(ID,pwd);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error0", "loginError");request.getRequestDispatcher("UpdateLoginPwd.jsp").forward(request, response);}else {request.setAttribute("error0", "nologinError");boolean result1 = service.updateLoginPwd(ID,pwd1);if(!result1) {request.getRequestDispatcher("UpdateLoginPwd.jsp").forward(request, response);}else {request.setAttribute("error1", "noupdateError");request.getRequestDispatcher("login.jsp").forward(request, response);}}}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

注销用户表示层(DeleteLoginIDServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;/*** Servlet implementation class DeleteLoginIDServlet*/
public class DeleteLoginIDServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");String ID = request.getParameter("UID");String pwd = request.getParameter("upwd");IStudentService service = new StudentServiceImpl();boolean result = service.checkLoginID(ID,pwd);boolean result1 = service.deleteLoginID(ID);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error2", "loginError");request.getRequestDispatcher("DeleteLoginID.jsp").forward(request, response);}else {request.setAttribute("error2", "nologinError");if(!result1) {request.setAttribute("error3", "deleteError");request.getRequestDispatcher("DeleteLoginID.jsp").forward(request, response);}else {request.setAttribute("error3", "nodeleteError");request.getRequestDispatcher("login.jsp").forward(request, response);}}}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

分页显示(QueryStudentByPageServlet.java)

package student.servlet;import java.io.IOException;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.entity.Page;
import student.entity.Student;
import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;public class QueryStudentByPageServlet extends HttpServlet {private static final long serialVersionUID = 1L;public QueryStudentByPageServlet() {super();}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {IStudentService studentService = new StudentServiceImpl();int count = studentService.getTotalCount();Page page = new Page();String cPage = request.getParameter("currentPage");if(cPage == null) {cPage = "0";}int currentPage = Integer.parseInt(cPage);page.setCurrentPage(currentPage);int totalCount = studentService.getTotalCount();page.setTotalCount(totalCount);int pageSize = 4;page.setPageSize(pageSize);List<Student> students = studentService.queryStudentsByPage(currentPage, pageSize);page.setStudents(students);request.setAttribute("page1", page);request.getRequestDispatcher("index.jsp").forward(request, response);}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

按学号查询学生信息(QueryStudentBySnoServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.entity.Student;
import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;public class QueryStudentBySnoServlet extends HttpServlet {/*** */private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("UTF-8");int sno = Integer.parseInt(request.getParameter("sno"));IStudentService service = new StudentServiceImpl();Student student = service.queryStudentBySno(sno);request.setAttribute("student", student);//将查询到的request信息放在request域中request.getRequestDispatcher("StudentInfo.jsp").forward(request,response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet(request, response);}}

增加学生信息(AddStudentServlet.java)

package student.servlet;import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.entity.Student;
import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;public class AddStudentServlet extends HttpServlet {/*** */private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");String name = request.getParameter("name");int sno = Integer.parseInt(request.getParameter("sno"));int age = Integer.parseInt(request.getParameter("age"));String dept = request.getParameter("dept");Student student = new Student(name, sno, age, dept);IStudentService studentService = new StudentServiceImpl();boolean result = studentService.addStudent(student);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error", "addError");}else {request.setAttribute("error", "noaddError");}request.getRequestDispatcher("QueryStudentByPageServlet").forward(request, response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet(request, response);}}

删除学生信息(DeleteStudentServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;/*** Servlet implementation class DeleteStudentServlet*/
public class DeleteStudentServlet extends HttpServlet {protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");int sno = Integer.parseInt(request.getParameter("sno"));IStudentService service = new StudentServiceImpl();boolean result = service.deleteStudentBySno(sno);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error1", "deleteError");}else {request.setAttribute("error1", "nodeleteError");}request.getRequestDispatcher("QueryStudentByPageServlet").forward(request, response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

修改学生信息表示层(UpdateStudentServlet.java)

package student.servlet;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import student.entity.Student;
import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;public class UpdateStudentServlet extends HttpServlet {/*** */private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("UTF-8");String name = request.getParameter("name");int sno = Integer.parseInt(request.getParameter("sno"));int age = Integer.parseInt(request.getParameter("age"));String dept = request.getParameter("dept");Student student = new Student(name, age, dept);System.out.println(sno);IStudentService service = new StudentServiceImpl();boolean result = service.updateStudentBySno(sno, student);response.setContentType("text/html;charest=UTF-8");response.setCharacterEncoding("utf-8");if(!result) {request.setAttribute("error2", "updateError");}else {request.setAttribute("error2", "noupdateError");}request.getRequestDispatcher("QueryStudentByPageServlet").forward(request, response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet(request, response);}}

上传作业(UploadServlet.java)

package student.servlet;import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadBase;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;import student.service.IStudentService;
import student.service.impl.StudentServiceImpl;public class UploadServlet extends HttpServlet {private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");response.setContentType("text/html; charset=UTF-8");String name = null;int sno = -1;boolean isMutipart = ServletFileUpload.isMultipartContent(request);if(isMutipart) {DiskFileItemFactory factory = new DiskFileItemFactory();ServletFileUpload upload = new ServletFileUpload(factory);factory.setRepository(new File("D:\uploadtemp"));List<FileItem> items = null;try {items = upload.parseRequest(request);} catch (FileUploadException e) {// TODO Auto-generated catch blocke.printStackTrace();}Iterator<FileItem> iter = items.iterator();while(iter.hasNext()) {FileItem item= iter.next();String fileName = item.getName();String itemName = item.getFieldName();if(item.isFormField()) {if(itemName.equals("name")){name = item.getString("utf-8");}else if(itemName.equals("sno")) {sno =Integer.parseInt(item.getString("utf-8"));}else {}}else {//定义上传路径:指定上传的位置String path = "D:\upload";File file = new File(path,fileName);try {item.write(file);} catch (Exception e) {e.printStackTrace();}}}IStudentService studentService = new StudentServiceImpl();boolean result = studentService.upLoadWork(sno,name);System.out.println(name+sno);System.out.println(result);if(!result) {request.setAttribute("error3", "uploadError");request.getRequestDispatcher("QueryStudentByPageServlet").forward(request, response);}else{request.setAttribute("error3", "nouploadError");request.getRequestDispatcher("QueryStudentByPageServlet").forward(request, response);}}}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubdoGet(request, response);}}

②业务逻辑层Service

Service接口(IStudentService.java)

package student.service;import java.util.List;import student.entity.Student;public interface IStudentService {//查询全部学生信息public List<Student> queryAllStudents();//按照学号查询学生信息public Student queryStudentBySno(int sno);//删除学生信息public boolean deleteStudentBySno(int sno) ;//更改学生信息public boolean updateStudentBySno(int sno, Student student) ;//增加学生信息public boolean addStudent(Student student) ;//查询总数据public int getTotalCount();//分页public List<Student> queryStudentsByPage(int current, int pageSize);//检查登陆账户和密码public boolean checkLoginID(String ID,String pwd);//注册账户public boolean addLoginID(String ID, String pwd);//更改密码public boolean updateLoginPwd(String ID,String pwd1);//注销账号public boolean deleteLoginID(String ID);//判断ID是否存在public boolean IDExist(String ID);//判断上传作业输入的学生信息是否存在public boolean upLoadWork(int sno, String name);}

接口的实现类(StudentServiceImpl.java)

package student.service.impl;import java.util.List;import student.dao.IStudentDao;
import student.dao.impl.StudentDaoImpl;
import student.entity.Student;
import student.service.IStudentService;
import student.util.DBUtil;//业务逻辑层:逻辑性的增删改查(增:查+增),对dao层进行的组装
public class StudentServiceImpl implements IStudentService{IStudentDao studentDao = new StudentDaoImpl();//查询全部学生信息public List<Student> queryAllStudents(){return studentDao.queryAllStudents();}//按照学号查询学生信息public Student queryStudentBySno(int sno) {return studentDao.queryStudentBySno(sno);}//删除学生信息public boolean deleteStudentBySno(int sno) {if(studentDao.isExist(sno)) {return studentDao.deleteStudentBySno(sno);}return false;}//更改学生信息public boolean updateStudentBySno(int sno, Student student) {return studentDao.updateStudentBySno(sno, student);}//增加学生信息public boolean addStudent(Student student) {if(!studentDao.isExist(student.getSno())) {studentDao.addStudent(student);return true;}else {System.out.println("学号重复!");return false;}}//查询总条数@Overridepublic int getTotalCount() {return studentDao.getTotalCount();}//查询当前页的数据集合@Overridepublic List<Student> queryStudentsByPage(int current, int pageSize) {return studentDao.queryStudentByPage(current, pageSize);}@Overridepublic boolean checkLoginID(String ID, String pwd) {return studentDao.checkLoginID(ID, pwd);}@Overridepublic boolean addLoginID(String ID, String pwd) {return studentDao.addLoginID(ID,pwd);}@Overridepublic boolean updateLoginPwd(String ID, String pwd1) {return studentDao.updateLoginPwd(ID,pwd1);}@Overridepublic boolean deleteLoginID(String ID) {return studentDao.deleteLoginID(ID);}@Overridepublic boolean IDExist(String ID) {return studentDao.IDExist(ID);}@Overridepublic boolean upLoadWork(int sno, String name) {return studentDao.upLoadWork(sno,name);}}

③数据访问层Dao

接口(IStudentDao.java)

package student.dao;import java.util.List;import student.entity.Student;public interface IStudentDao {public boolean updateLoginPwd(String ID,String pwd1);//查询全部学生信息public List<Student> queryAllStudents();//判断此人是否存在public boolean isExist(int sno) ;//增加学生信息public boolean addStudent(Student student);//删除学生信息public boolean deleteStudentBySno(int sno);//根据sno找到要修改的学生,然后再进行修改public boolean  updateStudentBySno(int sno,Student student);//根据学号查询学生信息public Student queryStudentBySno(int sno);//查询总数据数public int getTotalCount();//currentPage:当前页(页码)pageSize:页面大小(每页显示的数据条数)public List<Student> queryStudentByPage(int currentPage,int pageSize);public boolean checkLoginID(String ID,String pwd);public boolean addLoginID(String ID, String pwd);public boolean deleteLoginID(String ID);public boolean IDExist(String ID);public boolean upLoadWork(int sno, String name);
}

接口的实现类(StudentDaoImpl.java)

package student.dao.impl;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;import student.dao.IStudentDao;
import student.entity.Student;
import student.util.DBUtil;public class StudentDaoImpl implements IStudentDao{private final String URL = "jdbc:mysql://localhost:3306/STUDENT?useSSL=false&serverTimezone=UTC";private final String UserName = "root";private final String Pwd = "123456";String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";//查询全部学生信息public List<Student> queryAllStudents(){PreparedStatement pstmt = null;Student student = null;List<Student> students = new ArrayList<>();ResultSet rs = null;try {String sql = "select * from student1";rs = DBUtil.executeQuery(sql, null);while(rs.next()) {int sno= rs.getInt("sno");String name = rs.getString("name");int age = rs.getInt("age");String dept = rs.getString("dept");student = new Student(name, sno, age, dept);students.add(student);}return students;} catch(Exception e) {e.printStackTrace();return null;}finally {DBUtil.closeAll(rs, pstmt, DBUtil.connection);}}//判断此人是否存在public boolean isExist(int sno) {return queryStudentBySno(sno) == null? false:true;}//增加学生信息public boolean addStudent(Student student) {String sql = "insert into student1(name,sno,age,dept) values(?,?,?,?)";Object[] params = {student.getName(),student.getSno(),student.getAge(),student.getDept()};return DBUtil.executeUpdate(sql, params);}//删除学生信息public boolean deleteStudentBySno(int sno) {String sql = "delete from student1 where sno =?";Object[] params = {sno};return DBUtil.executeUpdate(sql, params);}//根据sno找到要修改的学生,然后再进行修改public boolean  updateStudentBySno(int sno,Student student) {String sql = "update student1 set name =?,age=?,dept=? where sno=?";Object[] params = {student.getName(),student.getAge(),student.getDept(),sno};return DBUtil.executeUpdate(sql, params);}//根据学号查询学生信息public Student queryStudentBySno(int sno){PreparedStatement pstmt = null;Student student = null;Connection connection = null;ResultSet rs = null;try {Class.forName(JDBC_DRIVER);connection = DriverManager.getConnection(URL,UserName,Pwd);String sql = "select * from student1 where sno = ?";pstmt = connection.prepareStatement(sql);pstmt.setInt(1, sno);rs = pstmt.executeQuery();if(rs.next()) {int no= rs.getInt("sno");String name = rs.getString("name");int age = rs.getInt("age");String dept = rs.getString("dept");student = new Student(name, no, age, dept);}return student;} catch (ClassNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();return null;} catch(SQLException e) {e.printStackTrace();return null;}catch(Exception e) {e.printStackTrace();return null;}finally {DBUtil.closeAll(rs, pstmt, DBUtil.connection);}}@Overridepublic int getTotalCount() {//查询总数据数String sql = "select count(1) from student1";return DBUtil.getTotalCount(sql);}@Overridepublic List<Student> queryStudentByPage(int currentPage, int pageSize) {String sql = "select * from student1 order by sno asc limit ?,?";Object[] params = {currentPage*pageSize,pageSize};List<Student> students = new ArrayList<>();ResultSet rs = DBUtil.executeQuery(sql, params);try {while(rs.next()) {Student student = new Student(rs.getString("name"),rs.getInt("sno"),rs.getInt("age"),rs.getString("dept"));students.add(student);}} catch (SQLException e) {e.printStackTrace();}catch (Exception e) {e.printStackTrace();}return students;}@Overridepublic boolean checkLoginID(String ID, String pwd){int count = 0;String sql = "select * from login where ID=? and pwd=?";Object[] params = {ID,pwd};ResultSet rs = DBUtil.executeQuery(sql, params);try {while(rs.next()) {count++;}if(count>0)return true;elsereturn false;} catch (SQLException e) {e.printStackTrace();}return false;}@Overridepublic boolean addLoginID(String ID, String pwd) {// TODO Auto-generated method stubString sql = "insert into login(ID,pwd) values(?,?)";Object[] params = {ID,pwd};return DBUtil.executeUpdate(sql, params);}@Overridepublic boolean updateLoginPwd(String ID, String pwd1) {String sql = "update login set pwd =? where ID=?";Object[] params = {pwd1,ID};return DBUtil.executeUpdate(sql, params);}@Overridepublic boolean deleteLoginID(String ID) {String sql = "delete from login where ID =?";Object[] params = {ID};return DBUtil.executeUpdate(sql, params);}@Overridepublic boolean IDExist(String ID) {String sql = "select *from login where ID = ?";Object[] params = {ID};return DBUtil.executeUpdate(sql, params);}@Overridepublic boolean upLoadWork(int sno, String name) {int count = 0;String sql = "select *from student1 where sno = ? and name = ?";Object[] params = {sno,name};ResultSet rs = DBUtil.executeQuery(sql, params);try {while(rs.next()) {count++;}if(count>0)return true;elsereturn false;} catch (SQLException e) {e.printStackTrace();}return false;}
}

④通用的数据库操作(DBUtils.java)

package student.util;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;import student.entity.Student;//通用的数据库操作方法
public class DBUtil {private static final String URL = "jdbc:mysql://localhost:3306/STUDENT?useSSL=false&serverTimezone=UTC";private static final String UserName = "root";private static final String Pwd = "123456";private static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";public static Connection connection = null;public static PreparedStatement pstmt = null;public static ResultSet rs = null;//查询总数public static int getTotalCount(String sql){int count = -1;try {pstmt = createPreParedStatement(sql,null);rs = pstmt.executeQuery();if(rs.next()) {count = rs.getInt(1);}} catch (SQLException e) {e.printStackTrace();}catch (Exception e) {e.printStackTrace();}finally {closeAll(rs,pstmt,connection);}return count;}//增删改public static boolean executeUpdate(String sql,Object[] params) {try {pstmt = createPreParedStatement(sql,params);int count = pstmt.executeUpdate();System.out.println(count);if(count>0) {return true;}else {return false;}} catch (ClassNotFoundException e) {e.printStackTrace();return false;} catch(SQLException e) {e.printStackTrace();return false;}catch(Exception e) {e.printStackTrace();return false;}finally {closeAll(null,pstmt,connection);}}public static void closeAll(ResultSet rs,Statement stmt,Connection connection){try{if(rs!=null)rs.close();if(pstmt!=null)pstmt.close();if(connection!=null)connection.close();}catch(SQLException e) {e.printStackTrace();}}public static PreparedStatement createPreParedStatement(String sql,Object[] params) throws ClassNotFoundException, SQLException {pstmt = getConnection().prepareStatement(sql);if(params!=null) {for(int i = 0;i<params.length;i++) {pstmt.setObject(i+1, params[i]);}}return pstmt;}public static Connection getConnection() throws ClassNotFoundException, SQLException {Class.forName(JDBC_DRIVER);return DriverManager.getConnection(URL,UserName,Pwd);}//通用的查public static ResultSet executeQuery(String sql,Object[] params){List<Student> students = new ArrayList<>();Student student = null;try {pstmt = createPreParedStatement(sql,params);rs = pstmt.executeQuery();return rs;} catch(SQLException e) {e.printStackTrace();return null;}catch(Exception e) {e.printStackTrace();return null;}}}

3.JavaBean封装数据

①分页帮助类(Page.java)

package student.entity;import java.util.List;//分页帮助类
public class Page {private int currentPage;private int pageSize;private int totalCount;private int totalPage;private List<Student> students;public Page() {}public Page(int currentPage, int pageSize, int totalCount, int totalPage, List<Student> students) {this.currentPage = currentPage;this.pageSize = pageSize;this.totalCount = totalCount;this.totalPage = totalPage;this.students = students;}public int getCurrentPage() {return currentPage;}public void setCurrentPage(int currentPage) {this.currentPage = currentPage;}public int getPageSize() {return pageSize;}public void setPageSize(int pageSize) {this.pageSize = pageSize;this.totalPage = this.totalCount%this.pageSize==0?this.totalCount/this.pageSize:this.totalCount/this.pageSize+1;}public int getTotalCount() {return totalCount;}public void setTotalCount(int totalCount) {this.totalCount = totalCount;}public int getTotalPage() {return totalPage;}public List<Student> getStudents() {return students;}public void setStudents(List<Student> students) {this.students = students;}
}

②封装学生信息(Student.java)

package student.entity;public class Student {private String name;private int sno;private int age;private String dept;public Student(int sno) {this.sno = sno;}public Student() {}public Student(String name, int age, String dept) {this.name = name;this.age = age;this.dept = dept;}public Student(String name, int sno, int age, String dept) {this.name = name;this.sno = sno;this.age = age;this.dept = dept;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getSno() {return sno;}public void setSno(int sno) {this.sno = sno;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public String getDept() {return dept;}public void setDept(String dept) {this.dept = dept;}public String toString() {return this.getSno()+"-"+this.getName()+"-"+this.getAge()+"-"+this.getDept();}
}

4.项目所需jar包

项目需要3个jar包,前两个jar包属于文件上传所需,最后一个为连接数据库的jar包

下载官网地址:https://mvnrepository.com/

五.数据库表格

本人用的是mysql数据库,直接在mysql数据库中新建表格

①登录注册表格login

②学生信息表格student1

最后

深知大多数初中级Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《Java开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

小编已加密:aHR0cHM6Ly9kb2NzLnFxLmNvbS9kb2MvRFVrVm9aSGxQZUVsTlkwUnc==出于安全原因,我们把网站通过base64编码了,大家可以通过base64解码把网址获取下来。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.yaotu.net/news/4715.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

HTTP协议中的“报头”(header)和 “正文“ (body)详解

系列文章目录 Fiddler抓包&#xff1a;下载、安装及使用_crazy_xieyi的博客-CSDN博客 HTTP协议格式、URL格式及URL encode_crazy_xieyi的博客-CSDN博客 GET和POST有什么区别&#xff1f;_crazy_xieyi的博客-CSDN博客 文章目录 一、请求“报头”(header)详解二、请求 "…

springboot校园师生出入登记系统java ssm

后台主要是管理员&#xff0c;管理员功能包括个人中心&#xff0c;通知公告管理&#xff0c;用户管理&#xff0c;工作人员管理&#xff0c;进门登记管理&#xff0c;出门登记管理&#xff0c;出入统计管理&#xff0c;外来登记管理等&#xff1b; 系统对这些功能进行整合 本次…

【操作系统】系统启动流程

文章目录系统启动流程&#xff08;Linux&#xff09;BIOSMBRGRUB2启动引导内核引导systemd固件和BIOSBIOS分类关于legacy关于uefibootloader 启动管理器kernel初始化systemd - 守护进程总结系统启动流程&#xff08;Linux&#xff09; 1. BIOS 加电自检 2. 把 MBR 加载到内存 …

MyBatis的各种查询功能(5种)

MyBatis的各种查询功能(5种) 查询一个实体类对象&#xff1a; 新建一个SelectMapper的接口文件 新建一个SelectMapper.xml的映射文件 新建一个测试类SelectMapperTest.java文件 在接口文件中添加查询一条语句的方法声明 在映射文件中添加sql语句 在测试类中编写查询一条语句…

spark(day04)

数据挖掘 数据挖掘∶也就是data mining&#xff0c;是一个很宽泛的概念&#xff0c;也是一个新兴学科&#xff0c;旨在如何从海量数据中挖掘出有用的信息来。 数据挖掘这个工作Bl&#xff08;商业智能&#xff09;可以做&#xff0c;统计分析可以做&#xff0c;大数据技术可以做…

哈希的使用

文章目录1. 哈希的使用1.1 unordered_set1.2 unordered_map1.3 测试效率2 练习题2.12.21. 哈希的使用 map、set和哈希的区别&#xff1a; map是双向迭代器&#xff0c;哈希表是单向迭代器。map有序&#xff0c;哈希无序。map查找是logn&#xff0c;哈希是O(1); 1.1 unordered…

Java | static关键字的应用【工具类、代码块和单例】

在上一篇文章讲完了static关键字的一些基础知识后&#xff0c;我们就来说一说这个关键字在应用开发中具体可以怎么使用吧&#xff0c;希望看完这篇文章可以对您有帮助&#x1f4d6; static关键字在具体开发中的应用一、工具类1、什么是工具类&#xff1f;2、使用工具类有什么好…

Spring

目录 1、Spring 1.1、简介 1.2、优点 1.3、组成 1.4、拓展 2、IOC理论推导 2.1、原来的实现 2.2、需求变更 2.3、改进 2.4、IOC本质 设计思想 2.5、Spring和IoC的关系 3、HelloSpring 3.1、基础环境 3.2、导包 3.3、编写代码 思考问题&#xff1f; 4、IOC创建…

grpc|protobuf的安装、编译、运行笔记(C++)

一、下载grpc源码 如果你的电脑/服务器可以做代理&#xff0c;然后稳定链接上 GitHub 那么完全可以按照 GitHub 的官方文档来操作&#xff0c;我这里采用 Gitee 镜像来操作 git clone https://gitee.com/jiangxy__loey/grpc.git二、下载依赖库 进入grpc目录&#xff0c;然后…

【数据结构】二叉树的顺序结构及实现,堆,向上调整算法,向下调整算法,数组建堆算法,堆排序

提示&#xff1a;学习本文之前&#xff0c;要先了解一下树的概念及结构&#xff0c;二叉树的概念及结构&#xff0c;详情请至博客。 文章目录1.二叉树的顺序结构2.堆的概念及结构3.堆的实现3.1堆的总实现3.2堆的向上调整算法---O(logN)3.3堆的向下调整算法---O(logN)4.数组建堆…

【JavaWeb】一文搞懂Response

文章目录1 Response继承体系2 Response响应2.1 响应行2.2 响应头2.3 响应体3 Response 重定向3.1 什么是重定向3.1.1 重定向实现的步骤3.1.2 例子3.2 重定向简化3.3 重定向的特点3.4 资源路径&#xff08;要不要加虚拟目录&#xff09;3.4.1 两种情况3.4.2 动态配置虚拟目录4 R…

python的脚本如何执行

运行python脚本的几种方法&#xff1a; 一. 终端命令行下 []$python "name.py" 二. python环境中 若脚本名称为name.py&#xff0c; 其内容为&#xff1a; a"head" b"hehe" print(a,b) 则使用 >>>impport name 针对此种方法我们使用下面…

vue路由传参

今天介绍路由传递参数的方式。首先要明白路由跳转的两种方式一种是声明式导航另一种是编程式导航。 参数的形式&#xff1a; params参数&#xff1a;属于路径中的一部分&#xff0c;需要注意的是在配置路由时需要占位query参数&#xff1a;不属于路径中的一部分&#xff0c;不…

Matter over Wi-Fi: Raspberry Pi 4开发环境设置

以下是使用 Raspberry Pi 4 通过 Wi-Fi 构建Matter的步骤: 入门 1. 刷入 SD 卡上的 Ubuntu 操作系统。 2. 将 SD 卡&#xff08;直接或使用读卡器&#xff09;插入运行 raspberry pi imager 工具的笔记本电脑/PC。 3. 启动 Raspberry Pi 4 成像仪。 4.点击“CHOOSE OS”…

戴尔服务器安装Debian11过程

目录物理戴尔服务器Debian11安装过程,以下皆为作者实操,转载注明出处.制作Debian ISO 镜像 U盘启动服务器进入启动项设置注意:在开机之前,*请一定拔掉服务器网线*,否则Debian安装会卡在安装软件这一步安装过程Debian设置网卡/设置IP开启root远程登录物理戴尔服务器Debian11安装…

python案例:百钱买鸡

python案例&#xff1a;百钱买鸡 案例目录python案例&#xff1a;百钱买鸡一、问题描述二、问题分析三、实战1、代码2、运行结果四、每日一句一、问题描述 一只公鸡值五钱&#xff1b;一只母鸡值三钱&#xff1b;三只小鸡值一钱&#xff1b;现在要用百钱买百鸡&#xff1b;请问…

瑞吉外卖代码优化

文章目录&#x1f68f; 1、缓存优化&#x1f680; 1、环境搭建&#x1f6ac; maven坐标&#x1f6ac; 配置文件&#x1f6ac; 配置类&#x1f684; 2、缓存短信验证码&#x1f6ac; 将验证码缓存在Redis中&#x1f6ac; 代码实现&#x1f692; 3、缓存菜品数据&#x1f6ac; 缓…

Java毕设项目——网上宠物店管理系统(java+SSM+Maven+Mysql+Jsp)

文末获取源码 开发语言&#xff1a;Java 框架&#xff1a;SSM 技术&#xff1a;Jsp JDK版本&#xff1a;JDK1.8 服务器&#xff1a;tomcat7 数据库&#xff1a;mysql 5.7/8.0 数据库工具&#xff1a;Navicat11 开发软件&#xff1a;eclipse/myeclipse/idea Maven包&#xff1a…

Python基于OpenCV的交通路口红绿灯控制系统设计

开发环境&#xff1a; PyCharm Python3.7 Sqlite OpenCV 功能介绍&#xff1a; 基于python和opencv库实现一个交通路口红绿灯控制系统&#xff0c;主要可以自动和手动控制红绿灯&#xff0c;还带有视频录像功能等&#xff0c;主要做的具体需求如下几点&#xff1a; 1、三…

Docker安装Redis并使用Another Redis Desktop Manager连接

Redis简单介绍 Redis全称是Remote DIctionary Service,即远程字典服务。Redis 是一个使用C语言编写的、开源的(遵守 BSD 协议)、高性能的、支持网络、可基于内存亦可持久化的日志型、Key-Value的NoSQL数据库。查看可用的 Redis 版本访问DokcerHub中的Redis镜像库地址:https…
最新文章