600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 基于javaweb的教室信息管理系统

基于javaweb的教室信息管理系统

时间:2021-08-11 05:59:46

相关推荐

基于javaweb的教室信息管理系统

一、系统简介

本项目采用eclipse工具开发,jsp+servlet+jquery技术编写,数据库采用的是mysql,navicat开发工具。

系统一共分为4个角色分别是:管理员,学生,老师,游客

二、模块简介

管理员

1、登录

2、学生管理

3、教室管理

4、游客管理

5、教室管理

6、教室申请管理

7、统计管理

学生,老师,游客

1、登录,注册

2、个人信息维护

3、查看教室

4、教室申请

5、使用记录

获取方式:基于javaweb的教室信息管理系统 - 九鸟网

三、项目截图

项目结构

数据库结构

登录

注册

首页

学生信息

教师信息

游客信息

教室信息

统计信息

四、代码简介

1、登录注册

用户启动项目后,系统默认加载登录页面login.jsp,用户填写账号密码,选择角色后,点击登录,系统使用jquery进行表单验证,验证通过后请求后台loginServlet类里面的login方法进行用户校验,成功后跳转main.jsp

<%@ page language="java" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";%><%@ taglib uri="/jsp/jstl/core" prefix="c"%><jsp:include page="/WEB-INF/common/header.jsp" /><script language="javascript">function check1(){ if(document.ThisForm.userName.value==""){alert("请输入用户名");document.ThisForm.userName.focus();return false;}if(document.ThisForm.password.value==""){alert("请输入密码");document.ThisForm.password.focus();return false;}if(document.ThisForm.type.value=="-1"){alert("请选择登录身份");document.ThisForm.type.focus();return false;}document.form1.submit();}function reg(){//参考/seamon_love/article/details/81698870var strUrl = "<%=path%>/LoginServlet?action=toRegiste";//var ret = window.open(strUrl,"","height=400, width=800, top=200, left=400, toolbar=no, menubar=yes, scrollbars=no, resizable=no, location=no, status=no");}</script></head><body><body><br><br><br><br><table width="559" height="423" border="0" align="center"cellpadding="0" cellspacing="0" background="<%=path%>/img/"><tr><td><div align="center"style="FONT-WEIGHT: bold; FONT-SIZE: 25pt;">教室信息管理系统</div></td></tr><tr><td width="559"><form name="ThisForm" method="post"action="LoginServlet?action=login"><table width="410" height="198" border="0" align="right"cellpadding="0" cellspacing="0"><tr><td height="5" colspan="2"></td></tr><tr><td width="356" valign="bottom">用户名:<input name="userName"type="text" class="input2"onMouseOver="this.style.background='#F0DAF3';"onMouseOut="this.style.background='#FFFFFF'"></td><span style="color: red">${msg}</span></tr><tr><td height="10" colspan="2" valign="bottom"></td></tr><tr><td height="31" colspan="2" valign="top" class="STYLE15">密&nbsp;&nbsp;码: <input name="password" type="password" size="21"class="input2" align="bottom"onMouseOver="this.style.background='#F0DAF3';"onMouseOut="this.style.background='#FFFFFF'"></td></tr><tr><td height="10" colspan="2" valign="bottom"></td></tr><tr style="display: block"><td height="31" colspan="2" valign="top" class="STYLE15">身&nbsp;&nbsp;&nbsp;&nbsp;份: <select class="INPUT_text"name="type"><option value="" selected="selected">请选择登录身份</option><option value="1">管理员</option><option value="2">学生</option><option value="3">教师</option><option value="4">游客</option></select></td></tr><tr><td colspan="2" valign="top">&nbsp; &nbsp; &nbsp; &nbsp; <inputname="button" type="submit" class="submit1" value="登录">&nbsp; <input name="button" type="button" class="submit1"value="注册" onclick="reg()"> <img id="indicator"src="<%=path%>/img/loading.gif" style="display: none" /></td></tr></table></form></td></tr></table></body>

protected void login(HttpServletRequest request, HttpServletResponse response) throws Exception {//跳转到添加用户界面String userName = request.getParameter("userName");String password = request.getParameter("password");String type = request.getParameter("type");if(type != null && type.equals("1")){//管理员 Admin admin = ls.selectAdmin(userName,password);if (admin == null) {request.setAttribute("msg","账号或者密码错误"); //绑定参数request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request,response);} else {request.getSession().setAttribute("type",1);request.getSession().setAttribute("admin",admin);request.getRequestDispatcher("/WEB-INF/views/main.jsp").forward(request,response);}}else if(type != null && type.equals("2")){//学生 Student student = ls.selectStudent(userName,password);if (student == null) {request.setAttribute("msg","学号或者密码错误"); //绑定参数request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request,response);} else {request.getSession().setAttribute("type",2);request.getSession().setAttribute("student",student);request.getRequestDispatcher("/WEB-INF/views/main.jsp").forward(request,response);}}else if(type != null && type.equals("3")){//教师Teacher teacher = ls.selectTeacher(userName,password);if (teacher == null) {request.setAttribute("msg","工号或者密码错误"); //绑定参数request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request,response);} else {request.getSession().setAttribute("type",3);request.getSession().setAttribute("teacher",teacher);request.getRequestDispatcher("/WEB-INF/views/main.jsp").forward(request,response);}}else if(type != null && type.equals("4")){//游客Tourist data = ls.selectTourist(userName,password);if (data == null) {request.setAttribute("msg","手机号或者密码错误"); //绑定参数request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request,response);} else {request.getSession().setAttribute("type",4);request.getSession().setAttribute("tourist",data);request.getRequestDispatcher("/WEB-INF/views/main.jsp").forward(request,response);}}else{request.setAttribute("msg","请选择登录角色"); request.getRequestDispatcher("/WEB-INF/views/login.jsp").forward(request,response);}}

学生信息列表

点击学生列表选项,系统通过studentServlet里面的studentList方法查询学生数据,返回给前端student_list.jsp中进行遍历显示

//管理员修改个人信息protected void studentList(HttpServletRequest request, HttpServletResponse response) throws Exception {//跳转到添加用户界面String p=request.getParameter("p");//接收页码System.out.println(p);int pageSize=6;//每页显示5条int pageNum=1; //默认第一页if(p!=null){pageNum= Integer.parseInt(p);}//调用分页查询List<Student> list=ss.getStudentPage(pageNum,pageSize);//携带参数到页面request.setAttribute("list",list); //绑定参数int nums=ss.queryStudentCount(); //查询总数//计算总页数int totalPage=(nums%pageSize==0)? (nums/pageSize):(nums/pageSize+1);request.setAttribute("cp",pageNum); //当前页request.setAttribute("tp",totalPage); //总页数//条件 值1:值2request.getRequestDispatcher("/WEB-INF/views/student/student_list.jsp").forward(request,response); //页面转发}

<%@ page language="java" pageEncoding="UTF-8"%><jsp:include page="/WEB-INF/common/header.jsp"/><%@ taglib uri="/jsp/jstl/core" prefix="c"%><%String path = request.getContextPath();%><script language="javascript">function del(id){if(confirm('您确定删除该条记录吗?')){window.location.href="<%=path %>/StudentServlet?action=deleteStudent&id="+id;}}</script></head><body leftmargin="2" topmargin="2" background='<%=path %>/img/allbg.gif'><form action="<%=path %>/StudentServlet?action=selectStudentLike" name="formAdd" method="post"><br> &emsp;姓名:<input type="text" name="name" size="20"/> <input type="submit" value="查询"/> </form><table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px"><tr bgcolor="#FAFAF1"><td height="14" colspan="1" >&nbsp;学生列表&nbsp;</td></tr><tr align="center" bgcolor="#FAFAF1" height="22"><td width="12%">姓名</td><td width="12%">学号</td><td width="12%">密码</td><td width="12%">邮箱</td><td width="12%">注册时间</td><td width="14%">操作</td></tr><c:forEach items="${list}" var="c" ><tr align='center' bgcolor="#FAFAF1" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22"><td width="12%" bgcolor="#FFFFFF" align="center">${c.name}</td><td width="12%" bgcolor="#FFFFFF" align="center">${c.stno}</td><td width="12%" bgcolor="#FFFFFF" align="center">${c.pwd}</td><td width="12%" bgcolor="#FFFFFF" align="center">${c.email}</td><td width="12%" bgcolor="#FFFFFF" align="center">${c.time}</td><td width="12%" bgcolor="#FFFFFF" align="center"><%-- <c:if test="${type==1 }"><button onclick="location.href='XkjlServlet?action=xuanke&id=${c.id }&stuno=${sessionScope.student.stuno }&sname=${sessionScope.student.sname }'">选课</button></c:if> --%><c:if test="${type == 1 }"><a href="StudentServlet?action=toUpdateStudent&id=${c.id }" >修改</a><a href="#" onclick="del(${c.id})" class="pn-loperator">删除</a></c:if></td></tr></c:forEach></table><br><div style="text-align: center"><a href="StudentServlet?action=studentList&p=1">首页</a><%-- 判断是否有上一页--%><c:if test="${cp>1}"><a href="StudentServlet?action=studentList&p=${cp-1}">上一页</a></c:if><%-- 循环显示页码--%><c:forEach begin="${cp-2>1 ? (cp-2) :1}" end="${cp+2>tp?tp:(cp+2)}" var="e"><%-- 判断是否是当前页--%><c:if test="${cp==e}"><a href="StudentServlet?action=studentList&p=${e}">${e}</a></c:if><c:if test="${cp!=e}"><a href="StudentServlet?action=studentList&p=${e}">${e}</a></c:if></c:forEach><%-- 判断是否有下一页--%><c:if test="${cp<tp}"><a href="StudentServlet?action=studentList&p=${cp+1}">下一页</a></c:if><a href="StudentServlet?action=studentList&p=${tp}">尾页</a></div></body></html>

其他相关代码都是类似的,主要是前端jsp和后端servlet交互比较重要!!!非开源!!!!!!

其他模块代码都是类似的,此项目适合初学者学习借鉴,项目整体比较简单,可用作于期末考核,课设,毕设等方面的作业!!!!!

喜欢的朋友的点赞加关注,感兴趣的同学可以研究!!!!!

感谢 = v =

项目截图中的数据,很多是用来测试的,需要自行添加合适的数据图片!!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。