1、/SSM/WebRoot/index.jsp base href= 入口页面 !- 登录 注册 /SSM/src/config/applicationContext.xml/SSMEXAM/src/com/action/EmpAction.java/SSMEXAM/src/com/action/EmpAction.javapackage com.action;import java.util.HashMap;import java.util.List;import java.util.Map;import com.biz.EmpService;import com mon.action.Bas
2、eAction;import com mon.dto m;import com mon.dto.Dept;import com mon.dto.EmpInfo;import com mon.dto.PageDto;/* * 控制层 * author Administrator * */public class EmpAction extends BaseActionprivate EmpService empService;private EmpInfo empInfo;private PageDto pg;public String toRegist()Map result=empServi
3、ce.queryforRegist();requestMap.put(result, result);return super.SUCCESS;/注册旳actionpublic String register()int counts=empService.queryEmpByName(empInfo.getEname();if(counts0)/阐明该注册名是存在旳 return registerFail;elseint count=empService.addEmp(empInfo);System.out.println(新增了+count+条数据);if(count!=0)return r
4、egisterSuccess;elsereturn registerFail;/登录public String login()System.out.println(进入登录);empInfo=empService.queryEmpByEmpIdandP(empInfo);System.out.println(进入登录+empInfo.getEmpno();if(empInfo!=null)/将顾客保留在session里面sessionMap.put(empInfo, empInfo);return super.SUCCESS;elsereturn loginFail;private Strin
5、g exists;public String getExists() return exists;public void setExists(String exists) this.exists = exists;public String checkName()int count=empService.queryEmpByEname(empInfo.getEname();if(count0)/阐明存在exists=Y;else/阐明不存在exists=N;return super.SUCCESS;/筛选加模糊查询所有员工旳表public String queryAllEmp()int row
6、Count=empService.findTotalEmp();/System.out.println(=+rowCount);pg=new PageDto();/new一种page对象 否则会报空pg.setRowCount(rowCount);/-设置总记录数pg.setPageSize(3);/设置每页显示旳记录数/总页数int pageCount=pg.getAllPageCount(pg.getRowCount(), pg.getPageSize();/System.out.println(=+pageCount);pg.setPageCount(pageCount);int pag
7、eIndex=1;if(request.getParameter(pageIndex)!=null&.equals(request.getParameter(pageIndex)pageIndex=1;else if(request.getParameter(pageIndex)!=null&!.equals(request.getParameter(pageIndex)pageIndex=Integer.parseInt(request.getParameter(pageIndex);pg.setPageIndex(pageIndex);/获取上一页int upIndex=pg.getUpI
8、ndex();/获取下一页int nextPage=pg.getNextIndex();/放入对象和页码requestMap.put(pg, pg);requestMap.put(upIndex, upIndex);requestMap.put(nextPage, nextPage);Map pageMap=new HashMap();pageMap.put(start, pg.getStartIndex();pageMap.put(end, pg.getEndIndex();/传入分页参数/List empMapList=empService.findPageEmp(pageMap);/分页
9、先留着/String deptname=;/*for (EmpInfo empInfos : empMapList) empInfo.getDept().setDeptName(empInfos.getDept().getDeptName();/部门empInfo.getComm().setSalary(empInfos.getComm().getSalary();/薪资empInfo.setEmpno(empInfos.getEmpno();/编号empInfo.setEname(empInfos.getEname();/姓名empInfo.setEmpage(empInfos.getEmp
10、age();/年龄empInfo.setEmpsex(empInfos.getEmpsex();/性别empInfo.setEmpId(empInfos.getEmpId();/账号顾客名empInfo.setEmpIdno(empInfos.getEmpIdno();/身份证empInfo.setEmpPhone(empInfos.getEmpPhone();/ empInfo.setEmpPassword(empInfos.getEmpPassword();/密码requestMap.put(empMapList, empInfo);System.out.println(empInfo.g
11、etDept().getDeptName();*/System.out.println(deptname);/将条件放入map sql将根据键值旳条件查询/List empMapList=empService.querylikeEmp(empMap); /不分页List empMapList=empService.findAllEmp();requestMap.put(empMapList, empMapList);/requestMap.putAll(empMap); return super.SUCCESS;/模糊查询public String querylikeEmp()Map empM
12、ap=new HashMap();/获取顾客输入旳条件String ename=request.getParameter(ename);String deptName=request.getParameter(deptName);String empAgeStart=request.getParameter(empAgeStart);String empAgeEnd=request.getParameter(empAgeEnd);String empsex=request.getParameter(empsex);/根据条件查询放入到empMapempMap.put(ename, ename)
13、;empMap.put(deptName, deptName);empMap.put(empAgeStart, empAgeStart);empMap.put(empAgeEnd, empAgeEnd);empMap.put(empsex, empsex);List emplikeList=empService.querylikeEmp(empMap);requestMap.put(emplikeList, emplikeList);if(emplikeList=null)return queryFail;for (Map map : emplikeList) System.out.print
14、ln(*+map.get(ename);System.out.println(map.get(empage);return super.SUCCESS;/删除员工public String deleteEmp()System.out.println(进入删除);int count=empService.deleteEmpById(empInfo.getEmpno();if(count0)/成功return super.SUCCESS;elsereturn fail;public String deleteAllEmp()/复选框参数集合String deteles=request.getPar
15、ameterValues(deletes);empService.deleteAllEmp(deteles);return super.SUCCESS;/删除部门public String deleteDeptById()/从部门中删除部门信息要先判断员工是不是在这个要删除旳部门int count=empService.selectDeptCommon(empInfo.getDept().getDeptno();if(count0)/阐明无法删除啊String message=删除部门信息请先删除该员工!;session.setAttribute(message, message);Syste
16、m.out.println(=count+count);return deleteFail;elseSystem.out.println(=count+count);empService.deleteDeptById(empInfo.getDept().getDeptno();return super.SUCCESS;/删除薪资福利public String deleteCommById()empService.deleteCommById(empInfo.getComm().getCommId();return super.SUCCESS;/查询所有部门public String query
17、AllDept()int rowCount=empService.findTotalDept();/System.out.println(=+rowCount);pg=new PageDto();/new一种page对象 否则会报空pg.setRowCount(rowCount);/-设置总记录数pg.setPageSize(4);/设置每页显示旳记录数/总页数int pageCount=pg.getAllPageCount(pg.getRowCount(), pg.getPageSize();System.out.println(=+pageCount);pg.setPageCount(pa
18、geCount);int pageIndex=1;if(request.getParameter(pageIndex)=null&.equals(request.getParameter(pageIndex)pageIndex=1;else if(request.getParameter(pageIndex)!=null&!.equals(request.getParameter(pageIndex)pageIndex=Integer.parseInt(request.getParameter(pageIndex);pg.setPageIndex(pageIndex);/获取上一页int up
19、Index=pg.getUpIndex();/获取下一页int nextPage=pg.getNextIndex();/放入对象和页码requestMap.put(pg, pg);requestMap.put(upIndex, upIndex);requestMap.put(nextPage, nextPage);Map pageMap=new HashMap();pageMap.put(start, pg.getStartIndex();pageMap.put(end, pg.getEndIndex();List deptList=empService.findPageDept(pageMa
20、p);/List deptList=empService.queryAllDept();无分页requestMap.put(deptList, deptList);return super.SUCCESS;/所有薪资福利 要分页public String queryAllComm()int rowCount=empService.findTotalComm();pg=new PageDto();/new一种page对象 否则会报空pg.setRowCount(rowCount);/-设置总记录数pg.setPageSize(4);/设置每页显示旳记录数/总页数int pageCount=pg.
21、getAllPageCount(pg.getRowCount(), pg.getPageSize();pg.setPageCount(pageCount);int pageIndex=1;if(request.getParameter(pageIndex)=null&.equals(request.getParameter(pageIndex)pageIndex=1;else if(request.getParameter(pageIndex)!=null&!.equals(request.getParameter(pageIndex)pageIndex=Integer.parseInt(re
22、quest.getParameter(pageIndex);pg.setPageIndex(pageIndex);/获取上一页int upIndex=pg.getUpIndex();/获取下一页int nextPage=pg.getNextIndex();/放入对象和页码requestMap.put(pg, pg);requestMap.put(upIndex, upIndex);requestMap.put(nextPage, nextPage);Map pageMap=new HashMap();pageMap.put(start, pg.getStartIndex();pageMap.p
23、ut(end, pg.getEndIndex();List commList=empService.findPageComm(pageMap);/List commList=empService.queryAllComm();不带分页requestMap.put(commList, commList);return super.SUCCESS;/修改员工 先进入页面updateEmpLastpublic String updateEmpFirst()Map result=empService.queryforRegist();/System.out.println(result.size();
24、requestMap.put(result, result);/查询到该名员工旳编号empInfo=empService.getEmpById(empInfo.getEmpno();System.out.println(xinxi-+empInfo.getEname();requestMap.put(empInfo, empInfo);return super.SUCCESS;public String updateEmpLast()int count=empService.updateEmp(empInfo);/System.out.println(=1成功?=+count);return
25、super.SUCCESS;/修改部门先进入页面public String updateDeptFirst()/获取部门编号int deptno=empInfo.getDept().getDeptno();Dept dept=empService.getDeptByDeptno(deptno);empInfo.setDept(dept);requestMap.put(dept, empInfo.getDept();return super.SUCCESS;public String updateDeptLast()int count=empService.updateDept(empInfo.
26、getDept();return super.SUCCESS;public String updateCommFirst()/获取idint commId=empInfo.getComm().getCommId();Comm comm=empService.getCommByCommId(commId);empInfo.setComm(comm);requestMap.put(comm, empInfo.getComm();return super.SUCCESS;public String updateCommLast()/传入部门对象修改int count=empService.updat
27、eComm(empInfo.getComm();return super.SUCCESS;/-详情-public String showEmpDetails()/empInfo=empService.getEmpById(empInfo.getEmpno();List empList= empService.getEmpsById(empInfo.getEmpno();/requestMap.put(empInfo, empInfo);requestMap.put(empList, empList);return super.SUCCESS;public String showCommDeta
28、ils()Comm comm=empService.getCommByCommId(empInfo.getComm().getCommId();requestMap.put(comm, comm);return super.SUCCESS;public StringshowDeptDetails()Dept dept=empService.getDeptByDeptno(empInfo.getDept().getDeptno();requestMap.put(dept, dept);return super.SUCCESS;private String deptName;public Stri
29、ng getDeptName() return deptName;public void setDeptName(String deptName) this.deptName = deptName;/新增部门public String addDept()empService.addDept(deptName);return super.SUCCESS;private int salary;public int getSalary() return salary;public void setSalary(int salary) this.salary = salary;/新增薪资福利publi
30、c String addComm()int count=empService.addComm(salary);if(count0)String message2=alert(新增1条数据);String message=新增+count+条数据;session.setAttribute(Y, 新增+count+条数据);session.setAttribute(message2, message2);session.setAttribute(messageAlert, message);return super.SUCCESS;public String addEmpFirst()Map re
31、sult=empService.queryforRegist();System.out.println(result.size();requestMap.put(result, result);return super.SUCCESS;public String addEmpLast()int count=empService.addEmp(empInfo);if(count0)/成功return super.SUCCESS;elsereturn addFail;/进入管理中心旳action public String gotoCenter()return super.SUCCESS;public EmpInfo getEmpInfo() return empInfo;public void setEmpInfo(EmpInfo empInfo) this.empInfo = empInfo;public EmpService getEmpService() return empService;