- 资源介绍
- 更新记录
Spring+Mybatis快速开发人员信息管理系统
相似案例
基于Javaweb的员工信息管理系统的设计与实现
基于Javaweb的学生信息管理系统的设计与实现
基于Javaweb的人员信息管理系统的设计与实现
项目介绍
案例:人员信息管理系统
主要技术:Servlet、JSP、Spring IOC、Spring AOP、Mybatis、Mybatis整合Spring、MySQL
开发环境:数据库MySQL5.7、Web容器Tomcat8.5、开发工具Intellij IDEA
项目结构
三层架构:持久层Mybatis、表现层Servlet+JSP、Spring管理对象,切面处理
基于MVC模式:视图JSP、模型JavaBean、控制器Servlet+JavaBean
效果展示
项目实现
数据库设计
SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for department -- ---------------------------- DROP TABLE IF EXISTS `department`; CREATE TABLE `department` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL, `address` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of department -- ---------------------------- BEGIN; INSERT INTO `department` VALUES (1, '人事部', '综合楼'); INSERT INTO `department` VALUES (2, '外交部', '北京'); COMMIT; -- ---------------------------- -- Table structure for log -- ---------------------------- DROP TABLE IF EXISTS `log`; CREATE TABLE `log` ( `opr_time` datetime NOT NULL, `type` varchar(10) NOT NULL, `operator` varchar(20) NOT NULL, `moudle` varchar(20) NOT NULL, `operation` varchar(20) NOT NULL, `result` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of log -- ---------------------------- BEGIN; INSERT INTO `log` VALUES ('2018-09-19 23:13:15', 'login', 'geek', 'SelfController', 'login', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:19', 'operation', 'geek', 'LogController', 'systemLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:20', 'operation', 'geek', 'LogController', 'loginLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:24', 'operation', 'geek', 'StaffController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:33', 'operation', 'geek', 'StaffController', 'edit', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:33', 'operation', 'geek', 'StaffController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:35', 'operation', 'geek', 'LogController', 'operationLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:45', 'operation', 'geek', 'LogController', 'loginLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:47', 'operation', 'geek', 'LogController', 'systemLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:48', 'operation', 'geek', 'LogController', 'operationLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:50', 'operation', 'geek', 'DepartmentController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:51', 'operation', 'geek', 'StaffController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:13:55', 'operation', 'geek', 'LogController', 'operationLog', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:14:02', 'operation', 'geek', 'StaffController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:14:03', 'operation', 'geek', 'DepartmentController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-19 23:14:06', 'operation', 'geek', 'LogController', 'operationLog', '成功'); INSERT INTO `log` VALUES ('2018-09-20 15:45:17', 'login', 'geek', 'SelfController', 'login', '成功'); INSERT INTO `log` VALUES ('2018-09-20 15:45:38', 'operation', 'geek', 'StaffController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-20 15:46:27', 'operation', 'geek', 'DepartmentController', 'list', '成功'); INSERT INTO `log` VALUES ('2018-09-20 15:46:42', 'operation', 'geek', 'LogController', 'operationLog', '成功'); INSERT INTO `log` VALUES ('2018-09-20 15:47:01', 'operation', 'geek', 'LogController', 'loginLog', '成功'); INSERT INTO `log` VALUES ('2018-09-20 15:47:15', 'operation', 'geek', 'LogController', 'systemLog', '成功'); COMMIT; -- ---------------------------- -- Table structure for staff -- ---------------------------- DROP TABLE IF EXISTS `staff`; CREATE TABLE `staff` ( `id` int(11) NOT NULL AUTO_INCREMENT, `account` varchar(20) NOT NULL, `password` varchar(20) NOT NULL, `status` varchar(10) NOT NULL, `did` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL, `sex` varchar(2) DEFAULT NULL, `id_number` char(18) DEFAULT NULL, `work_time` datetime DEFAULT NULL, `leave_time` datetime DEFAULT NULL, `born_date` date DEFAULT NULL, `info` varchar(200) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of staff -- ---------------------------- BEGIN; INSERT INTO `staff` VALUES (1, 'geek', '111111', '1', 1, 'geekerstar', '男', '38424923482', '2018-09-19 22:48:46', '2018-09-19 22:48:51', '2018-09-12', NULL); INSERT INTO `staff` VALUES (2, 'hehe', '123456', '正常', 1, '哈哈', '男', '3242343534534', '2018-09-19 22:50:15', NULL, '2010-04-02', '213231'); COMMIT; SET FOREIGN_KEY_CHECKS = 1;
项目结构
- sm:父Module、全局定义与组织
- sm_service:持久层、业务层
- sm_web:表现层、Servlet依赖
Spring全局配置
<?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:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!--spring整合mybatis--> <!-- 配置数据源--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql:///sm?useUnicode=true&characterEncoding=utf-8"/> <property name="username" value="root"/> <property name="password" value="210819"/> </bean> <!-- Mybatis配置--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="typeAliasesPackage" value="com.geekerstar.sm.entity"/> </bean> <!-- 自动映射--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.geekerstar.sm.dao"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> <!--声明式事务--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true"/> <tx:method name="find*" read-only="true"/> <tx:method name="search*" read-only="true"/> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="txPointcut" expression="execution(* com.geekerstar.sm.service.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/> </aop:config> <!--全局扫描--> <context:component-scan base-package="com.geekerstar.sm"/> <aop:aspectj-autoproxy/> </beans>
部分代码
编码过滤器
import javax.servlet.*; import java.io.IOException; public class EncodingFilter implements Filter { private String encoding = "UTF-8"; @Override public void init(FilterConfig filterConfig) throws ServletException { if (filterConfig.getInitParameter("ENCODING")!=null) encoding = filterConfig.getInitParameter("ENCODING"); } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { servletRequest.setCharacterEncoding(encoding); servletResponse.setCharacterEncoding(encoding); filterChain.doFilter(servletRequest,servletResponse); } @Override public void destroy() { encoding=null; } }
配置文件
<!-- 编码过滤器--> <filter> <filter-name>Encoding</filter-name> <filter-class>com.geekerstar.sm.global.EncodingFilter</filter-class> <init-param> <param-name>ENCODING</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
核心控制器
Servlet对象由Web容器管理、Service对象由IOC容器管理
import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import javax.servlet.GenericServlet; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class DispatcherServlet extends GenericServlet { private ApplicationContext context; public void init() throws ServletException { super.init(); context = new ClassPathXmlApplicationContext("spring.xml"); } @Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { HttpServletRequest request =(HttpServletRequest)servletRequest; HttpServletResponse response = (HttpServletResponse)servletResponse; String path = request.getServletPath().substring(1); String beanName= null; String methodName =null; int index = path.indexOf('/'); if (index!=-1){ beanName=path.substring(0,index)+"Controller"; methodName = path.substring(index+1,path.indexOf(".do")); }else{ beanName="selfController"; methodName = path.substring(0,path.indexOf(".do")); } Object obj = context.getBean(beanName); try { Method method = obj.getClass().getMethod(methodName,HttpServletRequest.class,HttpServletResponse.class); try { method.invoke(obj,request,response); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } catch (NoSuchMethodException e) { e.printStackTrace(); } } }
<servlet> <servlet-name>Global</servlet-name> <servlet-class>com.geekerstar.sm.global.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Global</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
猜你喜欢
-
基于java Swing的雷电游戏设计与实现
2019-06-04 -
基于Javaweb的员工/学生信息管理系统的设计与实现
2019-07-11 -
基于BS架构的Javaweb就业信息平台的设计与实现JSP+SSM+MYSQL
2019-06-04 -
基于Java的飞机大战游戏的设计与实现
2019-06-04 -
基于SSM框架的办公自动化OA系统的设计与实现
2019-07-11 -
基于Java Swing的聊天室软件的设计与实现
2019-06-06 -
基于Javaweb和jsp的电子政务网的设计与实现
2019-06-06 -
【项目源码】基于Javaweb的百货中心供应链管理系统的设计与实现
2019-05-02 -
【极客轻聊】基于SpringBoot、Netty、Websocket的Web即时通讯平台
2020-08-27 -
基于Javaweb的码头船只出行及配套货柜码放管理系统的设计与实现
2019-06-07
-
基于Javaweb的企业合同管理系统的设计与实现
2019-06-06 -
基于Javaweb的土地档案管理系统的设计与实现
2019-06-06 -
【项目源码】基于Javaweb的动漫论坛的设计与实现
2019-05-04 -
2019互联网大厂高频重点面试题(第二季)思维导图脑图笔记完整版下载
2019-07-07 -
基于Javaweb的固定资产管理系统的设计与实现
2019-06-04 -
【项目源码】基于Javaweb的病历管理系统设计与实现
2019-05-02 -
基于Javaweb的商品供应管理系统的设计与实现
2019-06-06 -
基于Javaweb的影视创作论坛的设计与实现
2019-06-06 -
【项目源码】基于javawe的SSM框架的个人博客系统的设计与实现
2019-05-04 -
【项目源码】基于Javaweb的超市积分管理系统的设计与实现
2019-05-02
猜你在找
猿码素材 » 基于Javaweb的员工/学生信息管理系统的设计与实现
常见问题FAQ
- 购买后由于自身原因导致无法使用可以退款吗?
- 由于源码的可复制性,原则上购买后是不提供退款服务的,购买前请务必联系客服或技术支持并提供必要信息以确认您是否能够使用该源码。另外可以点击右侧获取本地试用版来自行验证代码可行性。购买之前一定要考虑清楚。
- 源码可以拿来商用吗?
- 源码的更新周期是多久?
- 购买后可以开发票吗?
- 2019-07-11Hi,初次和大家见面了,请多关照!