1、项目功能演示
DC00024基于web实验室预约管理系统ssm教室预约实验室预约管理系统java web项目MySQL
2、项目功能描述
基于ssm实验室预约管理系统分为用户和系统管理员两个角色。
2.1 系统管理员
1、系统登录
2、用户管理:修改个人信息、修改个人密码、教师管理、学生管理
3、实验室管理:新增实验室、查看实验室
4、预约信息管理:排班表、高级搜索
5、公告管理:发布公告、删除公告
2.2 教师
1、系统登录
2、用户管理:查看个人信息、修改个人密码
3、预约管理:预约实验室(个人预约、课程预约)、查看预约信息、实验室排期表、高级搜索
4、课程管理:新增课程、课程列表
2.3 学生
1、系统登录
2、用户管理:查看个人信息、修改个人密码
3、预约管理:预约实验室、查看预约信息、实验室排期表、高级搜索
3、项目运行截图
4、项目核心代码
4.1 ApplicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.2.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <context:component-scan base-package="com.lrms.*"><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan> <!-- 配置数据源,引用数据池c3p0.jar包 --><!-- 通过加载jdbc配置文件使用数据源信息 --><!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.classname}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.user}"/> <property name="password" value="${jdbc.password}"/> </bean> --> <!-- 直接定义数据源的信息 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass"> <value>com.mysql.jdbc.Driver</value> </property> <property name="jdbcUrl"> <value>jdbc:mysql://localhost:3305/lrms?useSSL=false&useUnicode=true&characterEncoding=utf8</value></property> <property name="user"> <value>root</value> </property> <property name="password"> <value>root</value></property> <property name="maxPoolSize"> <value>80</value> </property> <property name="minPoolSize"> <value>1</value> </property> <property name="initialPoolSize"> <value>1</value> </property> <property name="maxIdleTime"> <value>20</value> </property> </bean> <!--定义Hibernate的SessionFactory --> <!-- SessionFactory使用的数据源为上面的数据源 --> <!-- 指定了Hibernate的映射文件和配置信息 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="show_sql">true</prop> <prop key="hibernate.jdbc.batch_size">20</prop> <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop></props> </property> <property name="packagesToScan" value="*" /> </bean> <!-- 定义事务管理器(声明式的事务) --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 扫描注解<tx:annotation-driven/> 就是支持事务注解的(@Transactional) <mvc:annotation-driven> 就是支持mvc注解的--><tx:annotation-driven transaction-manager="transactionManager"/> </beans>
4.2 spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:beans="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.2.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.2.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> <!-- 加载Spring的全局配置文件 --> <beans:import resource="ApplicationContext.xml" /> <!-- 配置静态资源信息 **指resources下的所有目录文件 --><mvc:resources location="/resource/" mapping="/resource/**"/><!-- 通过component-scan 让Spring扫描*下的所有的类,让Spring的代码注解生效 --> <!-- 扫描器只扫描到controller --><context:component-scan base-package="com.lrms.*"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/></context:component-scan><!-- 配置解析器,默认使用ISO-8859-1字符集,需要设置在 annotation-driven之前,用来修改ContextType中的字符集,设置在annotation-driven之后则无法生效--><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"><property name="messageConverters"><list><ref bean="stringMessageConvert" /><ref bean="jacksonMessageConvert" /></list></property></bean><!-- 启动两个类 DefaultAnnotationHandlerMapping(解析RequestMapping注解,放入map当中) AnnotationMethodHandlerAdapter(适配器来执行自己编写的controller)spring3.1之后 被替代为RequestMappingHandlerMapping RequestMappingHandlerAdapter--><mvc:annotation-driven></mvc:annotation-driven><!-- 视图解析器 bean的ID和 DispatcherServlet中的名称一致 --><!-- jsp页面放在 /WEB-INF/目录下--><bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/jsp/" /><property name="suffix" value=".jsp"/></bean><!-- 对RequestParam,ResponseBody注解 解析JSON格式数据的转换器 --><bean id="jacksonMessageConvert" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"><property name="supportedMediaTypes"><list><value>text/html;charset=utf-8</value> <!-- IE FireFox --><value>application/json;charset=utf-8</value> <!-- Chrome --></list></property></bean><!-- 对RequestParam,ResponseBody注解 解析字符数据的转换器 --><bean id="stringMessageConvert" class="org.springframework.http.converter.StringHttpMessageConverter"><property name="supportedMediaTypes"><list><value>text/html;charset=utf-8</value></list></property></bean><!-- 配置Spring文件上传 --><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><property name="defaultEncoding" value="UTF-8"></property><property name="maxUploadSize" value="5400000"></property> <!-- 单位字节 1024*1024*10 10MB 是上传文件的大小,单位为字节--><property name="maxInMemorySize" value="20480"></property> <!-- 在内存中的最大大小 --><property name="resolveLazily" value="true"></property><!-- <property name="uploadTempDir" value="fileUpload/temp"></property> --></bean><mvc:interceptors><mvc:interceptor><mvc:mapping path="/**"/><mvc:exclude-mapping path="/resource/**"/><mvc:exclude-mapping path="/**"/><bean class="com.lrms.interceptor.LoginInterceptor"></bean></mvc:interceptor></mvc:interceptors>
</beans>
4.3 预约action
package com.lrms.controller;import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;import com.lrms.other.ExecResult;
import com.lrms.entity.Course;
import com.lrms.entity.Laboratory;
import com.lrms.entity.Reservation;
import com.lrms.entity.Term;
import com.lrms.entity.lab_reservation;
import com.lrms.entity.lab_schedule;
import com.lrms.entity.user_lab_reservation;
import com.lrms.service.LaboratoryService;
import com.lrms.service.ReserveLaboratoryService;
import com.lrms.service.UserService;import org.apache.commons.lang.StringUtils;@Controller
public class ReserveController {@Autowiredprivate ReserveLaboratoryService reserveLaboratoryService;@Autowiredprivate LaboratoryService laboratoryService;@Autowiredprivate UserService userService;@RequestMapping("getLabReserveById")public ModelAndView getLabReserveById(HttpServletRequest request,HttpSession session){ModelAndView view=new ModelAndView("reservation");int lab_id=Integer.parseInt(request.getParameter("lab_id"));int user_id=Integer.parseInt(request.getParameter("user_id"));List<lab_reservation> lab_reservation_list=reserveLaboratoryService.getLab_reservations(lab_id);view.addObject("lab_reservation_list",lab_reservation_list);view.addObject("lab_id", lab_id);List<Term> termList=userService.getTermList();view.addObject("termList",termList);List<Course> courseList=userService.getCourseList(user_id);view.addObject("courseList",courseList);return view;}@RequestMapping("reserveLab")@ResponseBodypublic ExecResult reserveLab(HttpSession session,HttpServletRequest request) throws ParseException{ExecResult er=new ExecResult();System.out.println("LaboratoryController - addLab");Reservation reservation=new Reservation();if(StringUtils.isNotBlank(request.getParameter("course_id"))){reservation.setCourse_id(Integer.parseInt(request.getParameter("course_id")));}if(StringUtils.isNotBlank(request.getParameter("lab_id"))){reservation.setLab_id(Integer.parseInt(request.getParameter("lab_id")));}if(StringUtils.isNotBlank(request.getParameter("user_id"))){reservation.setUser_id(Integer.parseInt(request.getParameter("user_id")));}if(StringUtils.isNotBlank(request.getParameter("reserve_type"))){reservation.setReserve_type(Integer.parseInt(request.getParameter("reserve_type")));}if(StringUtils.isNotBlank(request.getParameter("time_interval"))){reservation.setTime_interval(Integer.parseInt(request.getParameter("time_interval")));}if(StringUtils.isNotBlank(request.getParameter("weekday"))){reservation.setWeekday(Integer.parseInt(request.getParameter("weekday")));}SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date create_time = sdf.parse(request.getParameter("create_time"));reservation.setCreate_time(create_time);SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); if(Integer.parseInt(request.getParameter("reserve_type"))==1){if(StringUtils.isNotBlank(request.getParameter("person_number"))){reservation.setPerson_number(Integer.parseInt(request.getParameter("person_number")));}Date reserve_date =(Date)sdf1.parse(request.getParameter("reserve_date"));reservation.setReserve_date(reserve_date);}else{if(StringUtils.isNotBlank(request.getParameter("person_number2"))){reservation.setPerson_number(Integer.parseInt(request.getParameter("person_number2")));}Date reserve_date = sdf1.parse(request.getParameter("reserve_date2"));reservation.setReserve_date(reserve_date);}if(StringUtils.isNotBlank(request.getParameter("modify_time"))){Date modify_time = sdf.parse(request.getParameter("modify_time"));reservation.setModify_time(modify_time);}if(StringUtils.isNotBlank(request.getParameter("courseName"))){reservation.setCourseName(request.getParameter("courseName"));}if(StringUtils.isNotBlank(request.getParameter("description"))){reservation.setDescription(request.getParameter("description"));}int result=(int)reserveLaboratoryService.reserveLab(reservation);if(result>0){er.setMsg("恭喜您,预约成功");er.setSuccess(true);}else{er.setMsg("实验室可供预约人数不够");er.setSuccess(false);}return er;} @RequestMapping("schedule_table")public ModelAndView schedule_table(HttpServletRequest request,HttpSession session){ModelAndView view=new ModelAndView("schedule_table");int lab_id=Integer.parseInt(request.getParameter("lab_id"));List<lab_schedule> list=reserveLaboratoryService.getSchedule_table(lab_id);List<Laboratory> labList=laboratoryService.getAllLab();view.addObject("labList",labList);view.addObject("list",list);return view;}//显示某个用户所有预约信息列表@RequestMapping("reservationByUser")public ModelAndView reservationByUser(HttpServletRequest request,HttpSession session){ModelAndView view=new ModelAndView("manage_reservation_info");int user_id=Integer.parseInt(request.getParameter("user_id"));int user_type=Integer.parseInt(request.getParameter("user_type"));List<lab_reservation> list=reserveLaboratoryService.reservationByUser(user_id);view.addObject("list",list);if(user_type==2){//获得属于该学生所在课堂的预约信息List<lab_reservation> list2=reserveLaboratoryService.ReservationTeacherForStudent(user_id);view.addObject("list2",list2);}return view;}/*//显示某个用户某条预约信息,并显示在update_reservation页面中@RequestMapping("single_reservation_info")public ModelAndView single_reservation_info(HttpServletRequest request,HttpSession session){ModelAndView view=new ModelAndView("update_reservation");int reserve_id=Integer.parseInt(request.getParameter("reserve_id"));lab_reservation lab_reservation=reserveLaboratoryService.single_reservation_info(reserve_id);view.addObject("lab_reservation",lab_reservation);return view;}*/@RequestMapping("deleteReservation")@ResponseBodypublic ExecResult deleteReservation(HttpSession session,HttpServletRequest request) {ExecResult er=new ExecResult();int reserve_id=Integer.parseInt(request.getParameter("reserve_id"));int result=(int)reserveLaboratoryService.deleteReservation(reserve_id);if(result>0){er.setMsg("恭喜您,成功取消预约");er.setSuccess(true);}else{er.setMsg("取消预约失败");er.setSuccess(false);}return er;}//课堂预约@RequestMapping("reserveLab2")@ResponseBodypublic ExecResult reserveLab2(HttpSession session,HttpServletRequest request) throws ParseException{ExecResult er=new ExecResult();int result=0;Reservation reservation=new Reservation();if(StringUtils.isNotBlank(request.getParameter("lab_id"))){reservation.setLab_id(Integer.parseInt(request.getParameter("lab_id")));}if(StringUtils.isNotBlank(request.getParameter("user_id"))){reservation.setUser_id(Integer.parseInt(request.getParameter("user_id")));}if(StringUtils.isNotBlank(request.getParameter("reserve_type"))){reservation.setReserve_type(Integer.parseInt(request.getParameter("reserve_type")));}if(StringUtils.isNotBlank(request.getParameter("course_id"))){reservation.setCourse_id(Integer.parseInt(request.getParameter("course_id")));}if(StringUtils.isNotBlank(request.getParameter("time_interval"))){reservation.setTime_interval(Integer.parseInt(request.getParameter("time_interval")));}SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date create_time = sdf.parse(request.getParameter("create_time"));reservation.setCreate_time(create_time);if(StringUtils.isNotBlank(request.getParameter("modify_time"))){Date modify_time = sdf.parse(request.getParameter("modify_time"));reservation.setModify_time(modify_time);}if(StringUtils.isNotBlank(request.getParameter("description"))){reservation.setDescription(request.getParameter("description"));}if(StringUtils.isNotBlank(request.getParameter("from"))&&StringUtils.isNotBlank(request.getParameter("end"))){String from=request.getParameter("from");String end=request.getParameter("end");int year1=Integer.parseInt(from.substring(0, 4));int month1=Integer.parseInt(from.substring(5, 7));int day1=Integer.parseInt(from.substring(8, 10));int year2=Integer.parseInt(end.substring(0, 4));int month2=Integer.parseInt(end.substring(5, 7));int day2=Integer.parseInt(end.substring(8, 10));if(StringUtils.isNotBlank(request.getParameter("weekday"))){int weekday=Integer.parseInt(request.getParameter("weekday"));Calendar calendar = new GregorianCalendar();//定义一个日历,变量作为年初Calendar calendarEnd = new GregorianCalendar();//定义一个日历,变量作为年末calendar.set(Calendar.YEAR, year1);calendar.set(Calendar.MONTH, month1-1);calendar.set(Calendar.DAY_OF_MONTH, day1-1);//设置年初的日期为1月1日calendarEnd.set(Calendar.YEAR, year2);calendarEnd.set(Calendar.MONTH, month2-1);calendarEnd.set(Calendar.DAY_OF_MONTH, day2-1);//设置年末的日期为12月31日SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");while(calendar.getTime().getTime()<=calendarEnd.getTime().getTime()){//用日期区间循环if(calendar.get(Calendar.DAY_OF_WEEK)==weekday+1){//判断如果为weekday时String date1=sf.format(calendar.getTime());Date date2=sf.parse(date1);reservation.setReserve_date(date2);reservation.setWeekday(weekday);result=reserveLaboratoryService.reserveLab(reservation);}calendar.add(Calendar.DAY_OF_MONTH, 1);//日期+1}}}if(result>0){er.setMsg("恭喜您,预约成功");er.setSuccess(true);}else{er.setMsg("实验室可供预约人数不够,请调整预约区间或课堂");er.setSuccess(false);}return er;}//高级搜索,根据用户、预约类别、预约期间等模糊搜索@RequestMapping("selectReservation")public ModelAndView selectReservation(HttpServletRequest request,HttpSession session){ModelAndView view=new ModelAndView("selectReservation");int user_type=0; String user_name=null;int reserve_type=0;String from=null;String end=null;int user_id=Integer.parseInt(request.getParameter("user_id"));if(StringUtils.isNotBlank(request.getParameter("user_type"))){user_type=Integer.parseInt(request.getParameter("user_type"));}if(StringUtils.isNotBlank(request.getParameter("user_name"))){user_name=request.getParameter("user_name");}if(StringUtils.isNotBlank(request.getParameter("reserve_type"))){reserve_type=Integer.parseInt(request.getParameter("reserve_type"));}if(StringUtils.isNotBlank(request.getParameter("from"))){from=request.getParameter("from");}if(StringUtils.isNotBlank(request.getParameter("end"))){end=request.getParameter("end");}System.out.println("bjhed");List<user_lab_reservation> list=reserveLaboratoryService.selectReservation(user_id,user_type,user_name,reserve_type,from,end);view.addObject("list1",list);return view;}}
4.4 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"><display-name>LRMS</display-name><welcome-file-list><welcome-file>jsp/login.jsp</welcome-file></welcome-file-list><!-- 监听spring上下文容器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener><listener-class>org.springframework.web.context.request.RequestContextListener</listener-class></listener> <listener><listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class></listener><!-- 加载spring的xml配置文件到 spring的上下文容器中 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:ApplicationContext.xml</param-value> </context-param> <!-- 配置spring先配置一个servlet,然后 加载LRMS的xml文件到Spring的上下文中。然后配置servlet-mapping,servlet-name为刚刚的servlet中的配置的name,然后指定要拦截的url为/--><servlet><servlet-name>LRMS</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!-- 初始化参数 ,加载LRMS的xml到 spring的上下文容器中 --> <init-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><!-- 配置DispatcherServlet所需要拦截的 url --> <servlet-mapping><servlet-name>LRMS</servlet-name><url-pattern>/</url-pattern> </servlet-mapping><filter><filter-name>encodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param><init-param><param-name>forceEncoding</param-name><param-value>true</param-value></init-param></filter><filter-mapping><filter-name>encodingFilter</filter-name><url-pattern>/*</url-pattern> </filter-mapping>
</web-app>
5、项目包含
6、项目获取
6.1 方式一
扫描下方名片获取文件。
6.2 方式二
点击此处直接获取项目文件。