基于javaweb的JSP+Servlet宿舍管理系统(java+jsp+javascript+servlet+struts+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

300023592402

310023592402

320023592402

330023592402

350023592402

基于javaweb的JSP+Servlet宿舍管理系统(java+jsp+javascript+servlet+struts+mysql)

项目介绍

本项目包含系统管理员、楼宇管理员、学生三种角色; 系统管理员角色包含以下功能: 登录页面,楼宇管理员管理,学生管理,楼宇管理,宿舍管理,入住登记,寝室调换,迁出登记,缺寝记录,迁出记录等功能。

楼宇管理员角色包含以下功能: 登录页面,学生管理,缺勤记录查询等功能。

学生角色包含以下功能: 登录页面,查看缺勤记录等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;  5.数据库:MySql 5.7版本; 6.是否Maven项目: 否;

技术栈

  1. 后端:servlet+struts 2. 前端:JSP+css+javacript

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中src/com/db/DBHelper.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/ 登录  系统管理员账号/密码:admin/admin 楼宇管理员账号/密码:louyu/123456 学生账号/密码: 001/123456

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43




public class TeacherUpdateSave extends ActionSupport {

//下面是Action内用于封装用户请求参数的属性
private String Teacher_ID ;
private String Teacher_Username ;
private String Teacher_Password ;
private String Teacher_Name ;
private String Teacher_Sex ;
private String Teacher_Tel ;
public String getTeacher_ID() {
return Teacher_ID;
}

public void setTeacher_ID(String cookID) {
Teacher_ID = cookID;
}

public String getTeacher_Username() {
return Teacher_Username;
}

public void setTeacher_Username(String cookUsername) {
Teacher_Username = cookUsername;
}

public String getTeacher_Password() {
return Teacher_Password;
}

public void setTeacher_Password(String cookPassword) {
Teacher_Password = cookPassword;
}

public String getTeacher_Name() {
return Teacher_Name;
}

public void setTeacher_Name(String cookName) {
Teacher_Name = cookName;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34



public class DomitoryAddSave extends ActionSupport {

//下面是Action内用于封装用户请求参数的属性
private String Domitory_BuildingID ;
private String Domitory_Name ;
private String Domitory_Type ;
private String Domitory_Number ;
private String Domitory_Tel ;


public String getDomitory_BuildingID() {
return Domitory_BuildingID;
}

public void setDomitory_BuildingID(String domitoryBuildingID) {
Domitory_BuildingID = domitoryBuildingID;
}

public String getDomitory_Name() {
return Domitory_Name;
}

public void setDomitory_Name(String domitoryName) {
Domitory_Name = domitoryName;
}

public String getDomitory_Type() {
return Domitory_Type;
}

public void setDomitory_Type(String domitoryType) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
		if(session.getAttribute("id")==null){
out.flush();out.close();return null;
}

//查询用户名是否存在
List<DomitoryBean> list=new DomitoryDao().GetList("Domitory_Name='"+Domitory_Name+"' and Domitory_BuildingID="+Domitory_BuildingID+" and Domitory_ID!="+Domitory_ID, "");
if(list.size()>0)
{
out.flush();out.close();return null;
}
//修改

DomitoryBean cnbean=new DomitoryBean();
cnbean=new DomitoryDao().GetBean(Integer.parseInt(Domitory_ID));
cnbean.setDomitory_BuildingID(Integer.parseInt(Domitory_BuildingID));
cnbean.setDomitory_Name(Domitory_Name);
cnbean.setDomitory_Type(Domitory_Type);
cnbean.setDomitory_Number(Domitory_Number);
cnbean.setDomitory_Tel(Domitory_Tel);
new DomitoryDao().Update(cnbean);

//跳转
out.flush();out.close();return null;

}

//判断是否空值
private boolean isInvalid(String value) {
return (value == null || value.length() == 0);
}

//测试
public static void main(String[] args) {
System.out.println();
}

}
package com.action;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
		
//解决乱码,用于页面输出
HttpServletResponse response=null;
response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();

//创建session对象
HttpSession session = ServletActionContext.getRequest().getSession();
//验证是否正常登录
if(session.getAttribute("id")==null){
out.flush();out.close();return null;
}
//查询条件
String strWhere="1=1";
if(!(isInvalid(SearchKey)))
{
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
}
if(!(isInvalid(Domitory_BuildingID)))
{
strWhere+=" and Domitory_BuildingID='"+Domitory_BuildingID+"'";
}

//查询所有楼宇
buildinglist=new BuildingDao().GetList("","Building_Name");

//查询所有
list=new DomitoryDao().GetList(strWhere,"Domitory_Name");

return SUCCESS;

}

//判断是否空值
private boolean isInvalid(String value) {
return (value == null || value.length() == 0);
}

//测试
public static void main(String[] args) {
System.out.println();
}

}
package com.action;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	return Building_Name;
}

public void setBuilding_Name(String buildingName) {
Building_Name = buildingName;
}

public String getBuilding_Introduction() {
return Building_Introduction;
}

public void setBuilding_Introduction(String buildingIntroduction) {
Building_Introduction = buildingIntroduction;
}

//处理用户请求的execute方法
public String execute() throws Exception {

//解决乱码,用于页面输出
HttpServletResponse response=null;
response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();

//创建session对象
HttpSession session = ServletActionContext.getRequest().getSession();
//验证是否正常登录
if(session.getAttribute("id")==null){
out.flush();out.close();return null;
}

//查询名称是否存在
List<BuildingBean> list=new BuildingDao().GetList("Building_Name='"+Building_Name+"' and Building_ID!="+Building_ID, "");
if(list.size()>0)
{
out.flush();out.close();return null;
}
//修改
BuildingBean cnbean=new BuildingBean();
cnbean=new BuildingDao().GetBean(Integer.parseInt(Building_ID));
cnbean.setBuilding_Name(Building_Name);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37



public class StudentQCSave extends ActionSupport {

//下面是Action内用于封装用户请求参数的属性
private String Student_ID ;
private String Out_Remark ;
public String getOut_Remark() {
return Out_Remark;
}

public void setOut_Remark(String outRemark) {
Out_Remark = outRemark;
}

public String getStudent_ID() {
return Student_ID;
}

public void setStudent_ID(String studentID) {
Student_ID = studentID;
}

//处理用户请求的execute方法
public String execute() throws Exception {

//解决乱码,用于页面输出
HttpServletResponse response=null;
response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();

//创建session对象
HttpSession session = ServletActionContext.getRequest().getSession();
//验证是否正常登录


项目链接:
https://javayms.github.io?id=021122582008200uo
https://javayms.pages.dev?id=021122582008200uo