【SSH】:基于Struts2+HIbernate3+Spring3实现员工管理系统之案例实现篇(上)

       案例:开发员工管理系统

       由于上一篇已经搭建了SSH开发环境,这一篇就来完成案例。过程不再赘述。

       创建的项目目录为:

       【SSH】:基于Struts2+HIbernate3+Spring3实现员工管理系统之案例实现篇(上)_第1张图片

       具体实现

       JSP页面

       1、index.jsp与frame.jsp及frame/*

       index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>





登陆





	

       frame.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>





主页



   
   
       
      
   

       frame/top.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>











	
欢迎您:
       frame/left.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>










	

       frame/right.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>








	

       2、jsp/department/*

       listDepartment.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>







     
	
部门管理
添加

部门名称 编辑 删除
"> ">

/    总记录数:   每页显示:   [首页]   ">[上一页]   ">[下一页]   ">[尾页]  

       addDepartment.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>





添加部门



	
部门添加
保存    退回


部门名称:
部门介绍:

       editDepartment.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>








	
编辑部门
保存    退回


部门名称:
部门介绍:

       3、jsp/employee/*

       listEpartment.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>








	
员工管理
添加

员工编号 员工姓名 性别 出生日期 入职时间 所在部门 编辑 删除
"> ">

/    总记录数:   每页显示:   [首页]   ">[上一页]   ">[下一页]   ">[尾页]  

       addEmployee.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>








	
员工添加
保存    退回


员工姓名: 性别:
出生日期: 入职日期:
用户名: 密码:
编号: 部门:

       editEmployee.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>








	
员工修改
保存    退回


员工姓名: 性别:
出生日期: " /> 入职日期: " />
用户名: 密码:
编号: 部门:

       实体类和对象关系映射文件

       Depaerment实体类

package com.employee.domain;

import java.util.HashSet;
import java.util.Set;

/**
 * 部门实体类
 * @author Administrator
 * @date 2016年12月24日
 */
public class Department {
	private Integer did;
	private String dname;
	private String ddesc;
	//部门员工的集合
	private Set employee = new HashSet();
	
	public Integer getDid() {
		return did;
	}
	
	public void setDid(Integer did) {
		this.did = did;
	}
	
	public String getDname() {
		return dname;
	}
	
	public void setDname(String dname) {
		this.dname = dname;
	}
	
	public String getDdesc() {
		return ddesc;
	}
	
	public void setDdesc(String ddesc) {
		this.ddesc = ddesc;
	}
	
	public Set getEmployee() {
		return employee;
	}
	
	public void setEmployee(Set employee) {
		this.employee = employee;
	}

}

       Department.hbm.xml




	
		
			
		
		
		
		
		
		
		
			
			
		
		
	


       Employee实体类

package com.employee.domain;

import java.util.Date;

/**
 * 员工实体
 * @author Administrator
 * @date 2016年12月24日
 */
public class Employee {
	private Integer eid;
	private String ename;
	private String sex;
	private Date birthday;
	private Date joinDay;
	private String eno;
	private String username;
	private String password;
	//员工的所属部门
	private Department department;
	
	public Integer getEid() {
		return eid;
	}
	
	public void setEid(Integer eid) {
		this.eid = eid;
	}
	
	public String getEname() {
		return ename;
	}
	
	public void setEname(String ename) {
		this.ename = ename;
	}
	
	public String getSex() {
		return sex;
	}
	
	public void setSex(String sex) {
		this.sex = sex;
	}
	
	public Date getBirthday() {
		return birthday;
	}
	
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	
	public Date getJoinDay() {
		return joinDay;
	}
	
	public void setJoinDay(Date joinDay) {
		this.joinDay = joinDay;
	}
	public String getEno() {
		return eno;
	}
	
	public void setEno(String eno) {
		this.eno = eno;
	}
	
	public String getUsername() {
		return username;
	}
	
	public void setUsername(String username) {
		this.username = username;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public Department getDepartment() {
		return department;
	}
	
	public void setDepartment(Department department) {
		this.department = department;
	}
	
}
       Employee.hbm.xml



    

	
		
			
		
		
		
		
		
		
		
		
		
		
		
		
		     
		
	
	

       PageBean实现类

package com.employee.domain;

import java.util.List;

/**
 * 分页Bean
 * @author Administrator
 * @date 2016年12月24日
 * @param 
 */
public class PageBean{
	private Integer currentPage;//当前页数
	private Integer pageCount;//每页显示记录数
	private Integer pageSize;//总页数
	private Integer totalSize;//总记录数
	private List list;     //每页显示的数据
	
	public Integer getCurrentPage() {
		return currentPage;
	}
	
	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	
	public Integer getPageCount() {
		return pageCount;
	}
	
	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}
	
	public Integer getPageSize() {
		return pageSize;
	}
	
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	
	public Integer getTotalSize() {
		return totalSize;
	}
	
	public void setTotalSize(Integer totalSize) {
		this.totalSize = totalSize;
	}
	
	public List getList() {
		return list;
	}
	
	public void setList(List list) {
		this.list = list;
	}
	
}

       下一篇就是三层的实现了。


       


你可能感兴趣的:(SSH,SSH框架学习之路)