中山中小企业网站制作,如何设计好的网页,代理ip注册网站都通不过,wordpress 导入导出SSM实战项目#xff1a;人事管理系统#xff08;蓝色版#xff09;
一、员工管理系统项目说明#xff1a;
该项目主要是完成SpringSpringMVCmybatis的完整整合#xff0c;功能实现比较单一#xff0c;就是一个完成增删改查的小项目#xff01;
完整代码下载地址SSM实…SSM实战项目人事管理系统蓝色版
一、员工管理系统项目说明
该项目主要是完成SpringSpringMVCmybatis的完整整合功能实现比较单一就是一个完成增删改查的小项目
完整代码下载地址SSM实战项目人事管理系统源码数据库使用说明
1、整个项目实现功能 1、管理员的登录注册br /2、员工的增删改查批量删除br /整个系统设计的目标人群是管理者系统的主要功能是对员工进行各种信息的操作。br /主要是完成对数据库的增删改查的功能。 2、开发环境
分类名称语种操作系统windows10简体中文数据库平台MySQL Server 8.0应用服务器apache-tomcat-8.5.71java开发工具idea框架mybatisSpringSpringMVC项目名称《学生教务系统》实现技术mybatisSpringSpringMVCmysqlServletjquerybootStrapjsMaventomcat等技术
3、数据库表设计
-- 创建员工表
create table t_emp(
id int primary key auto_increment,
name varchar(20) not null,
salary double not null,
age int not null
)-- 添加员工数据
insert into t_emp values(null,王恒杰,20000,21);
insert into t_emp values(null,杨福君,9000,19);
-- 查询员工数据
select * from t_emp;-- 创建管理员表
create table t_admin(id int primary key auto_increment,username varchar(20),password varchar(50)
)
-- 添加数据
insert into t_admin values(null,王恒杰,123456);
-- 查询
select * from t_admin4、Maven导入项目所依赖的jar包 !--junit--dependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.11/versionscopetest/scope/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context-support/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-jdbc/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-aop/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-beans/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-expression/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-aspects/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-tx/artifactIdversion4.3.2.RELEASE/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-web/artifactIdversion4.3.2.RELEASE/version/dependency!--springmvc核心依赖--dependencygroupIdorg.springframework/groupIdartifactIdspring-webmvc/artifactIdversion4.3.2.RELEASE/version/dependency!--servlet-api--dependencygroupIdjavax.servlet/groupIdartifactIdservlet-api/artifactIdversion2.5/versionscopeprovided/scope/dependency!--jsp--dependencygroupIdjavax.servlet.jsp/groupIdartifactIdjsp-api/artifactIdversion2.1/version/dependency!--jstl标签库--dependencygroupIdjstl/groupIdartifactIdjstl/artifactIdversion1.2/version/dependency!--mysql驱动jar--dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion8.0.16/version/dependency!--mybatis相关依赖--dependencygroupIdorg.mybatis/groupIdartifactIdmybatis/artifactIdversion3.4.6/version/dependency!--mybatis和spring的整合jar--dependencygroupIdorg.mybatis/groupIdartifactIdmybatis-spring/artifactIdversion1.3.1/version/dependency5、Springmybatis整合工厂applicationContext.xml !--1.开启注解扫描--context:component-scan base-packagecom.tjcu.whj/context:component-scan!--2.加载 jdbc.properties小配置文件--context:property-placeholder locationclasspath:jdbc.properties/context:property-placeholder!--3.加载数据源--bean classcom.alibaba.druid.pool.DruidDataSource namedataSourceproperty namedriverClassName value${jdbc.driver}/propertyproperty nameurl value${jdbc.url}/propertyproperty nameusername value${jdbc.username}/propertyproperty namepassword value${jdbc.password}/property/bean!--4.SqlSessionFactory--bean classorg.mybatis.spring.SqlSessionFactoryBean idsqlSessionFactory!--1.依赖于数据源--property namedataSource refdataSource/property!--2:mapper文件--property namemapperLocations valueclasspath:com/tjcu/mapper/*DaoMapper.xml/property!--3.别名--property nametypeAliasesPackage valuecom.tjcu.whj.entity/property/bean!--5.dao--bean classorg.mybatis.spring.mapper.MapperScannerConfigurer!--sqlSessionFactory--property namesqlSessionFactoryBeanName valuesqlSessionFactory/property!--依赖于DAO接口类型 --property namebasePackage valuecom.tjcu.whj.dao/property/bean!--6.事务管理器--bean classorg.springframework.jdbc.datasource.DataSourceTransactionManager idtransactionManagerproperty namedataSource refdataSource/property/bean!--7.开启注解式事务控制--tx:annotation-driven transaction-managertransactionManager/tx:annotation-driven6、SpringSpringMVC整合工厂Spring-mvc.xml !--1.开启注解式扫描--context:component-scan base-packagecom.tjcu.whj/context:component-scan!--2.注册处理器映射器(解析URL路径)handlerMapping处理器适配器参数处理handlerAdapter--mvc:annotation-driven/!--3.注册视图解析器--bean classorg.springframework.web.servlet.view.InternalResourceViewResolver!--前缀--property nameprefix value//property!--后缀--property namesuffix value.jsp/property/bean!--4.处理静态资源拦截问题--mvc:default-servlet-handler/二、管理员登录/注册模块功能开发 功能模块登录注册注销密码加密 注册示意图 登录示意图 1、dao层adminDao.java
public interface AdminDao {/*** 登录* param admin* return*/public Admin login(Admin admin);/*** 注册* param admin*/public void register(Admin admin);
}2、Service层
1adminService接口层
public interface AdminService {/*** 登录* param admin* return*/public Admin login(Admin admin);/*** 注册* param admin*/public void register(Admin admin);
}2adminServiceImpl实现类
Service(adminService)
Transactional
public class AdminServiceImpl implements AdminService {Autowiredprivate AdminDao adminDao;Overridepublic Admin login(Admin admin) {return adminDao.login(admin);}Overridepublic void register(Admin admin) {adminDao.register(admin);}
}
3、功能测试adminTest
public class AdminTest {Testpublic void login(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);AdminService adminService (AdminService) context.getBean(adminService);Admin admin new Admin(null,null, 王恒杰, 123456,true);Admin login adminService.login(admin);System.out.println(login);}Testpublic void register(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);AdminService adminService (AdminService) context.getBean(adminService);Admin admin new Admin(null, 风犬少年,邓正武, 234567,true);adminService.register(admin);}
}4、Controller层
Controller(adminController)
RequestMapping(admin)
public class AdminController {/*** 将adminService到AdminController中*/Autowiredprivate AdminService adminService;/*** 登录* param admin* return*/RequestMapping(login)public String login(Admin admin,HttpServletRequest request){String password MD5Utils.md5(admin.getPassword());admin.setPassword(password);Admin admin1 adminService.login(admin);System.out.println(admin1);if(admin1!null){request.getSession().setAttribute(admin,admin1);return redirect:/emp/show;}return redirect:/login.jsp;}/*** 注册* param admin*/RequestMapping(register)public String register(Admin admin){String password MD5Utils.md5(admin.getPassword());admin.setPassword(password);adminService.register(admin);return redirect:/login.jsp;}/*** 注销登录* return*/RequestMapping(destroy)public String destroy(HttpServletRequest request){request.getSession().invalidate();return redirect:/login.jsp;}}
三、员工增删改查功能模块的开发 员工的增删改查功能 员工展示页面 添加员工示意图 修改员工示意图 1、dao层empDao.java
public interface EmpDao {/*** 添加员工** param emp*/public void insert(Emp emp);/*** 删除员工* param id*/public void deleteById(Integer id);/*** 展示员工* return*/public ListEmp showEmp();/*** 修改员工* param emp*/public void updateEmp(Emp emp);/*** 数据回显* param id* return*/public Emp selectEmpById(Integer id);
}2、Service层
1empService接口层
public interface EmpService {/*** 添加员工** param emp*/public void insert(Emp emp);/*** 删除员工* param id*/public void deleteById(Integer id);/*** 展示员工* return*/public ListEmp showEmp();/*** 修改员工* param emp*/public void updateEmp(Emp emp);/*** 数据回显* param id* return*/public Emp selectEmpById(Integer id);
}
2)empServiceImpl实现类
Service(empService)
/*** 控制事务*/
Transactional
public class EmpServiceImpl implements EmpService {/*** 将empDao注入进Service组件中*/Autowiredprivate EmpDao empDao;public void setEmpDao(EmpDao empDao) {this.empDao empDao;}Overridepublic void insert(Emp emp) {empDao.insert(emp);}Overridepublic void deleteById(Integer id) {empDao.deleteById(id);}OverrideTransactional(propagation Propagation.SUPPORTS)public ListEmp showEmp() {return empDao.showEmp();}Overridepublic void updateEmp(Emp emp) {empDao.updateEmp(emp);}OverrideTransactional(propagation Propagation.SUPPORTS)public Emp selectEmpById(Integer id) {return empDao.selectEmpById(id);}
}3、功能测试EmpTest
public class EmpTest {/*** 添加员工*/Testpublic void insert(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);EmpService empService (EmpService) context.getBean(empService);Emp emp new Emp(null,邓正武,2000d,22);empService.insert(emp);}/*** 删除员工*/Testpublic void deleteById(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);EmpService empService (EmpService) context.getBean(empService);empService.deleteById(4);}/*** 展示员工* return*/Testpublic void showEmp(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);EmpService empService (EmpService) context.getBean(empService);ListEmp emps empService.showEmp();for (Emp emp : emps) {System.out.println(emp);}}/*** 修改员工*/Testpublic void updateEmp(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);EmpService empService (EmpService) context.getBean(empService);Emp emp new Emp(3,邓正武,38000d,23);empService.updateEmp(emp);}/*** 数据回显* return*/Testpublic void selectEmpById(){ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext(applicationContext.xml);EmpService empService (EmpService) context.getBean(empService);Emp emp empService.selectEmpById(1);System.out.println(emp);}
}
4、Controller层
Controller(emoController)
RequestMapping(emp)
public class EmpController {/*** 注入empService在EmpController中*/Autowiredprivate EmpService empService;/*** 添加员工** param emp*/RequestMapping(insert)public String insert(Emp emp){empService.insert(emp);return redirect:/emp/show;}/*** 删除员工* param emp*/RequestMapping(delete)public String deleteById(Emp emp){empService.deleteById(emp.getId());return redirect:/emp/show;}/*** 展示员工* return*/RequestMapping(show)public String showEmp(Model model){//调用业务方法ListEmp emps empService.showEmp();//作用域model.addAttribute(emps,emps);return emplist;}/*** 修改员工* param emp*/RequestMapping(update)public String updateEmp(Emp emp){empService.updateEmp(emp);return redirect:/emp/show;}/*** 数据回显* param id* return*/RequestMapping(select)public String selectEmpById(Integer id,Model model){Emp emp empService.selectEmpById(id);model.addAttribute(emp,emp);return updateEmp;}
}完整代码下载地址SSM实战项目人事管理系统源码数据库使用说明