基于SSH+MySQL+Bootstrap的高校学生宿舍管理系统

登陆

学生管理

楼宇管理

学生管理

楼宇管理

学生管理

添加学生

宿舍管理

入住登记

调换寝室

迁出登记

迁出登记

缺勤查询

技术描述

开发工具: Idea/Eclipse
数据库: mysql
Jar包仓库: Jar包
前段框架:jquery/Jsp
后端框架: Spring+Structs2+Hibernate

资料说明

基于SSH+MySQL+Bootstrap的高校学生宿舍管理系统,分为管理员,教师,学生三个角色。整体功能包含,楼宇管理员管理,学生管理,楼宇管理,宿舍管理,学生入住登记,学生寝室调换,学生迁出,学生缺勤记录,密码修改等。

package com.student.action;

import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;

import com.dao.*;
import com.info.bean.*;


public class StudentAddSave extends ActionSupport { 
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	//下面是Action内用于封装用户请求参数的属性
	private String Student_Username ;
    private String Student_Password ;
    private String Student_Name ;
    private String Student_Sex ;
    private String Student_Class ;
    
	public String getStudent_Username() {
		return Student_Username;
	}

	public void setStudent_Username(String studentUsername) {
		Student_Username = studentUsername;
	}

	public String getStudent_Password() {
		return Student_Password;
	}

	public void setStudent_Password(String studentPassword) {
		Student_Password = studentPassword;
	}

	public String getStudent_Name() {
		return Student_Name;
	}

	public void setStudent_Name(String studentName) {
		Student_Name = studentName;
	}

	public String getStudent_Sex() {
		return Student_Sex;
	}

	public void setStudent_Sex(String studentSex) {
		Student_Sex = studentSex;
	}

	public String getStudent_Class() {
		return Student_Class;
	}

	public void setStudent_Class(String studentClass) {
		Student_Class = studentClass;
	}

	//处理用户请求的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.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
			out.flush();
			out.close();
			
			return null;
		}
		
		//查询用户名是否存在
		List<StudentBean> list=new StudentDao().GetList("Student_Username='"+Student_Username+"'", "");
		if(list.size()>0) {
			out.print("<script language='javascript'>alert('用户名已经存在!');history.back(-1);</script>");
			out.flush();
			out.close();
			
			return null;
		}
		//添加
		StudentBean cnbean=new StudentBean();
		cnbean.setStudent_Username(Student_Username);
		cnbean.setStudent_Password(Student_Password);
		cnbean.setStudent_Name(Student_Name);
		cnbean.setStudent_Sex(Student_Sex);
		cnbean.setStudent_Class(Student_Class);
		cnbean.setStudent_State("未入住");
		cnbean.setStudent_DomitoryID(0);
		new StudentDao().Add(cnbean);
		    
		//跳转
		out.print("<script language='javascript'>alert('添加成功!');window.location='StudentManager.action';</script>");
		out.flush();
		out.close();
		
		return null; 
	} 
}

package com.student.action;

import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;

import com.dao.*;
import com.info.bean.*;


public class StudentManager extends ActionSupport { 
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	//下面是Action内用于封装用户请求参数的属性
	private List<StudentBean> list;
	
	public List<StudentBean> getList() {
		return list;
	}
	public void setList(List<StudentBean> list) {
		this.list = list;
	}
	private String SearchRow;
	private String SearchKey;
	private String State;
	public String getState() {
		return State;
	}
	public void setState(String state) {
		State = state;
	}
	public String getSearchRow() {
		return SearchRow;
	}
	public void setSearchRow(String searchRow) {
		SearchRow = searchRow;
	}
	public String getSearchKey() {
		return SearchKey;
	}
	public void setSearchKey(String searchKey) {
		SearchKey = searchKey;
	}
	//处理用户请求的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.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
			out.flush();out.close();return null;
		}
		//查询条件
		String strWhere="1=1";
		if(!(isInvalid(SearchKey))) {
			strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
		}
		if(!(isInvalid(State))) {
			strWhere+=" and Student_State='"+State+"'";
		}
		else {
			strWhere+=" and Student_State='入住'";
		}
		//查询所有
		list=new StudentDao().GetAllList(strWhere,"Student_Name");
	
		return SUCCESS;
		
	}
	
	//判断是否空值
	private boolean isInvalid(String value) {
		return (value == null || value.length() == 0);
	} 	
}

猜你喜欢

转载自blog.csdn.net/qq_36155000/article/details/125579480