当前位置: 移动技术网 > IT编程>开发语言>Java > 详解使用SSM实现简单工作流系统之实现篇

详解使用SSM实现简单工作流系统之实现篇

2019年07月19日  | 移动技术网IT编程  | 我要评论

项目说明

本项目是依据《轻量级 java ee 企业应用实战 第4版》的最后一章中的项目实现的,原本项目使用的框架是struts2 + spring 4 + hibernate,因为本人在学习spring mvc + spring + mybatis,所以将它重写了一次,使用了spring mvc + spring + mybatis项目。在正文中介绍项目的时候,也将主要依据原书的叙述。

因为项目是根据原始项目实现的,实现过程中可能出现有bug,如果发现问题可以与我联系,或在评论区中留言评论。

零,准备工作

首先根据建立ssm基本项目;也可以直接从github上直接下载, 下载之后, 在目录initproject下面有一个hrsystem项目,这个项目就是初始项目了。这个项目是根据前面提供的链接实现的,整合了基本的ssm框架,直接部署tomcat就可以运行了,部署方式可以直接参考前面的链接。该项目下还有一个目录就是originalproject,该目录存放的是原书中的项目代码,也是本文代码的参考实现。

github地址

hrsystem: https://github.com/sysukinthon/hrsystem (包含项目初始项目和原始ssh项目)
hrsystem_dev: https://github.com/sysukinthon/hrsystem_dev (包含完整的ssm项目代码) 

上面的项目都是idea项目,下载到相应的项目后,运行步骤如下:

  • 在idea中打开
  • 建立下数据库,数据库使用mysql,sql文件在src/main/resource目录下,叫做schema.sql。
  • 修改下项目中的spring-mybatis.xml里面关于数据库的配置,主要修改用户名和密码。
  • 上述都配置好后,再配置一下tomcat就可以了。

一,项目背景及系统结构

1)应用背景

项目实现的是一个简单的工作流系统,该系统包含公司日常的事务:日常考勤,工资结算及签核申请等。该签核系统完成了考勤改变申请的送签,以及对申请的签核,这是一种简单的工作流,,可以提高企业的生产效率,另外,本应用额外的打卡系统,自动工资结算等,也可以在一定程度上提高企业的生产效率。

2)系统功能介绍

系统的用户主要分为两种:普通员工和经理。

普通员工的功能包括

  • 员工通过打卡完成每天上下班的考勤记录,考勤记录包括迟到,早退,旷工等;
  • 员工也可以查看本人最近3天的考勤情况;
  • 如果发现考勤情况与实际不符,可提出申请,申请将由系统自动转发给员工经理,如果经理通过核准,则此申请自动生效,系统将考勤必为实际的情况;
  • 员工也可以查看自己的工资记录

经理的功能包括

  • 包含上述普通员工的功能,但是经理的考勤不能提出申请;
  • 签核员工申请
  • 新增员工
  • 查看管理的全部员工
  • 查看员工的上月工资

3)系统结构

  • 表现层:由jsp页面组成
  • mvc层:使用mvc框架技术(spring mvc)
  • 业务逻辑层:主要由spring ioc容器管理的业务逻辑组件组成(门面模式)
  • dao层:由6个dao组件组成
  • 领域对象层:由7个持久化对象组成(使用贫血模式设计)
  • 数据库服务层:使用mysql数据库存储持久化数据

4)系统功能模块

本系统可以大致分为两个模块:经理模块和员工模块,其主要业务逻辑通过empmanagerservice和mgrmanagerservice两个业务逻辑组件来实现,因此可以使用这两个业务组件来封装dao组件。

系统以业务逻辑组件作为dao组件的门面,封装这些dao组件,业务逻辑组件底层依赖于这些dao组件,向上实现系统的业务逻辑功能

本系统主要有如下6个dao对象

  • applicationdao:提供对application_inf表的基本操作
  • attenddao:提供对attend_inf表的基本操作
  • attendtypedao:提供对attend_type_inf表的基本操作
  • checkbackdao:提供对checkback_inf表的基本操作
  • employeedao:提供对employee_inf表的基本操作
  • paymentdao:提供对payment_inf表的基本操作

系统提供了两个业务逻辑组件:

  • empmanagerserivce:提供employee角色所需业务逻辑功能的实现
  • mgrmanagerservice:提供manager角色所需业务逻辑功能的实现

二,持久层设计

1)设计持久化实体

面向对象分析,是指根据系统需求提取应用中的对象,将这些对象抽象成类,再抽取出需需要持久化保存的类,这些需要持久化保持的类就是持久化对象(po)。

本项目一共设计了7个持久化类

  • application: 对应普通员工的考勤提出申请,包含申请理由,是否被批复及申请改变的类型等属性
  • attend: 对应每天的考勤,包含考勤时间,考勤员工,是否上班及考勤类别等信息
  • attendtype: 对应考勤的类别,包含考勤的名称,如迟到,早退等
  • checkback: 对应批复,包含该批复对应的申请,是否通过申请,由哪个经理完成批复等属性
  • employee: 对应系统的员工信息,包含员工的用户名,密码,工资以及对应的经理等属性
  • manager: 对应系统的经理信息,公包含经理管理的部门名。实际上,manager继承了employee类,因此该类同样包含employee的所有属性
  • payment: 对应每月所发的薪水信息,包含发薪月份,领薪员工和薪资数等信息

本应用采用贫血模式来设计它们,所以持久化类中不提供业务逻辑方法,而是将所有的业务逻辑方法放到业务逻辑组件中实现。

当采用贫血模式的架构模型时,系统中的领域对象十分简洁,它们都是单纯的数据类,不需要考虑到底应该包含哪些业务逻辑方法,因此开发起来非常便捷;而系统的所有的业务逻辑都由业务逻辑组件负责实现,可以将业务逻辑的变化限制在业务逻辑层内,从而避免扩散到两个层,因此降低了系统的开发难度。

7个po的关系如下:

  • employee是manager的父类,同时manager和employee之间存在 1-n的关系,即一个manager对应多个employee,但每个employee只能对应一个manager
  • employee和payment之间是1-n的关系,即每个员工可以多次领取薪水
  • employee和attend之间存在1-n的关系,即每个员工可以参与多次考勤,但每次考勤只对应一个员工
  • manager继承了employee类,因此具有employee的全部属性,另外manager还不慌不忙 checkback之间存在1-n的关系
  • application与attend之间存在n-1的关系,即每个attend可以被对应多次申请。
  • application与attendtype之间存在n-1的关系,即每次申请都有明确的考勤类型,而一个考勤类型可以对应多个申请
  • attend与attendtype之间存在n-1的关系,即每个attend只属于一个attendtype。

根据上面书写如下的schema.sql,也就是数据库文件

create database if not exists hrsystem collate = 'utf8_general_ci' character set = 'utf8';
 
use hrsystem;

create table attend_type_inf
(
 type_id int auto_increment,
 amerce_amount double not null,
 type_name varchar(50) not null,
 primary key(type_id)
);
 
 
create table employee_inf
(
 emp_id int auto_increment,
 emp_type int,
 emp_name varchar(50) not null,
 emp_pass varchar(50) not null,
 emp_salary double not null,
 mgr_id int,
 dept_name varchar(50),
 primary key(emp_id),
 unique key(emp_name),
 foreign key(mgr_id) references employee_inf(emp_id)
);
 
 
create table attend_inf
(
 attend_id int auto_increment,
 duty_day varchar(50) not null,
 punch_time datetime,
 is_come boolean not null,
 type_id int not null,
 emp_id int not null,
 primary key(attend_id),
 foreign key(type_id) references attend_type_inf(type_id),
 foreign key(emp_id) references employee_inf(emp_id)
);
 
 
create table application_inf
(
 app_id int auto_increment,
 attend_id int not null,
 app_reason varchar(255),
 app_result boolean,
 type_id int not null,
 primary key(app_id),
 foreign key(type_id) references attend_type_inf(type_id),
 foreign key(attend_id) references attend_inf(attend_id)
);
 
 
create table payment_inf
(
 pay_id int auto_increment,
 pay_month varchar(50) not null,
 pay_amount double not null,
 emp_id int not null,
 primary key(pay_id),
 foreign key(emp_id) references employee_inf(emp_id)
);
 
 
create table checkback_inf
(
 check_id int auto_increment,
 app_id int not null,
 check_result boolean not null,
 check_reason varchar(255),
 mgr_id int not null,
 primary key(check_id),
 foreign key(app_id) references application_inf(app_id),
 foreign key(mgr_id) references employee_inf(emp_id)
);
 
 
insert into `test_user` values ('1', '123455@qq.com','12345', 'test');
 
 
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '正常', 0);
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '事假', -20);
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '病假', -10);
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '迟到', -10);
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '早退', -10);
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '旷工', -30);
insert into attend_type_inf ( type_name , amerce_amount)
 values ( '出差', 10);
 
 
# 插入经理
insert into employee_inf (emp_type , emp_name , emp_pass , emp_salary , mgr_id , dept_name)
 values (2, 'oracle', 'oracle' , 5000 , null , 'db部');
insert into employee_inf (emp_type , emp_name , emp_pass , emp_salary , mgr_id , dept_name)
 values (2, 'weblogic', 'weblogic' , 6000 , null , 'server部');
# 员工
insert into employee_inf (emp_type , emp_name , emp_pass , emp_salary , mgr_id)
 values (1 , 'mysql', 'mysql' , 3000 , 1);
insert into employee_inf (emp_type , emp_name , emp_pass , emp_salary , mgr_id)
 values (1 , 'hsql', 'hsql' , 3200 , 1);
insert into employee_inf (emp_type , emp_name , emp_pass , emp_salary , mgr_id)
 values (1 , 'tomcat', 'tomcat' , 2800 , 2);
insert into employee_inf (emp_type , emp_name , emp_pass , emp_salary , mgr_id)
 values (1 , 'jetty', 'jetty' , 2560 , 2);

上面已经陈述了全部的设计,剩下的一些细节将在下面的代码实现中说明。

三,model层

为了节约篇幅,下面的所有实现都只针对employee类来说明,如有必要会针对其他进行说明

持久化实体类的存放目录是com.kevin.hrsystem.model,下面是employee持久化类的源码:

package com.kevin.hrsystem.model;
 
public class employee {
 private long id;
 private int type;
 private string name;
 private string password;
 private double salary;
 private manager manager;
 
 public long getid() {
  return id;
 }
 
 public void setid(long id) {
  this.id = id;
 }
 
 public int gettype() {
  return type;
 }
 
 public void settype(int type) {
  this.type = type;
 }
 
 public string getname() {
  return name;
 }
 
 public void setname(string name) {
  this.name = name;
 }
 
 public string getpassword() {
  return password;
 }
 
 public void setpassword(string password) {
  this.password = password;
 }
 
 public double getsalary() {
  return salary;
 }
 
 public void setsalary(double salary) {
  this.salary = salary;
 }
 
 public manager getmanager() {
  return manager;
 }
 
 public void setmanager(manager manager) {
  this.manager = manager;
 }
 
 @override
 public string tostring() {
  string rsl = "employee [id=" + this.id + ", name=" + this.name + ", password=" + this.password + ", type=" + this.type + ", salary=" + this.salary;
  if(this.manager != null) {
   rsl += ", managerid=" + this.manager.getid() + ", managername=" + this.manager.getname() + "]";
  }
  return rsl;
 }
}

在这里针对employee.java和manager.java进行一点说明,这两个的数据库表都是employee_inf,但是employee没有dept_name(部门名称),而manager没有mgr_id(所属部门经理id)

其他的model对象这里就不多说,直接参考源码即可。

四,dao(data access object)层

1)dao组件的定义

在持久层之上,可以使用dao组件再次封装数据库操作,这也是java ee应用里常用的dao模式。当使用dao模式时,既体现了业务逻辑组件封装dao组件的门面模式,也可分离业务逻辑组件和dao组件的功能:业务逻辑组件负责业务逻辑的变化,而dao组件负责持久化技术的变化,这也正是桥接模式的使用。

引入dao模式后,每个dao组件包含了数据库的访问逻辑;每个dao组件可对一个数据库表完成基本的curd等操作。

dao模式是一种更符合软件工程的开发方式,使用dao模式有如下理由:

  • dao模式抽象出数据访问方式,业务逻辑组件无须理会底层的数据库访问细节,而只专注于业务逻辑的实现,业务逻辑组件只负责业务功能的变化
  • dao将数据访问集中在独立的一层,所有的数据访问都由dao对象完成,这层独立的dao分离了数据访问的实现与其他业务逻辑,使得系统更具可维护性
  • dao还有助于提升系统的可移植性,独立的dao层使得系统能在不同的数据库之间轻易切换,底层的数据库实现对于业务逻辑组件是透明的。数据库移植时仅仅影响dao层,不同数据库的切换也不会影响业务逻辑组件,因此提供了系统的可复用性

dao组件提供了各持久化对象的基本的crud操作,而在dao接口里则对dao组件包含的各种crud方法提供了声明。使用dao接口的原因是:避免业务逻辑组件与特定的dao组件耦合

尽管很多的dao组件方法需要根据业务逻辑需求的变化而变化,但是还是有一些通用的方法,在代码实现中,basedao接口包含了几个通用的方法,其定义如下:

package com.kevin.hrsystem.dao; 
import java.util.list; 
public interface basedao<t> { 
 void save(t entity); //保持持久化实例 
 void delete(long id); //根据主键删除持久化实例 
 void update(t entity); //更新持久化实例 
 t findbyid(long id); //根据主键加载持久化实例
  list<t> findall(); //获取数据表中全部的持久化实例
}

dao接口无须给出任何实现,仅仅是dao组件包含的crud方法的定义,这些方法定义的实现取决于底层的持久化技术,dao组件的实现既可以使用传统的jdbc,也可以采用hibernate,mybatis等技术。

如下是我们的employeedao组件接口的源码

package com.kevin.hrsystem.dao;
 
import com.kevin.hrsystem.model.employee;
import com.kevin.hrsystem.model.manager;
import org.apache.ibatis.annotations.param;
 
import java.util.list;
 
public interface employeedao extends basedao<employee>{
 /**
  * 根据用户名和密码查询员工
  * @param name 用户名
  *  password 密码
  * @return 返回员工
  */
 public employee findbynameandpass(@param("name")string name, @param("password") string password);
 
 public employee findbyname(@param("name")string name);
 
 public list<employee> findemployeesbymgrid(@param("id") long id);
 
 public void saveasemployee(employee employee);
 
 public void saveasmanager(manager manager);
}

其他的dao组件接口的源码请直接查看代码;这里有一个要明确的,就是持久化对象里面有employee和manager,但是dao组件里面只有employeedao,因为这两个持久化对象对应的其实是同一个数据库表,在实现的过程中,我将两个持化对象的crud整合到同一个dao组件里面了。

dao接口只定义了dao组件应该实现的方法,但如何实现这些dao方法则没有任何限制,程序可以使用任何持久化技术来实现它们,这样就可以让dao组件来负责持久化技术这个维度的变化,当系统需要在不同的持久化技术之间迁移时,应用只需要提供不同的dao实现类即可,程序的其他部分无须进行任何改变,这就很好地提高了系统的可扩展性。

2)dao组件的实现

在本项目中,dao层的实现是使用了mybatis技术,在基础项目中, 我们已经在spring中引入了mybatis,其配置文件(spring-mybatis.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: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/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
 
 <!--扫描service包下所有注解的类型-->
 <context:component-scan base-package="com.kevin.hrsystem.service"/>
 
 <!--配置数据库相关参数properties的属性-->
 <context:property-placeholder location="classpath:jdbc.properties"/>
 
 <!--配置数据源-->
 <bean id="datasource" class="com.mchange.v2.c3p0.combopooleddatasource">
  <property name="driverclass" value="${jdbc.driver}"/>
  <property name="jdbcurl" value="${jdbc.url}"/>
  <property name="user" value="${jdbc.username}"/>
  <property name="password" value="${jdbc.password}"/>
  <property name="maxpoolsize" value="${c3p0.maxpoolsize}"/>
  <property name="minpoolsize" value="${c3p0.minpoolsize}"/>
  <property name="autocommitonclose" value="${c3p0.autocommitonclose}"/>
  <property name="checkouttimeout" value="${c3p0.checkouttimeout}"/>
  <property name="acquireretryattempts" value="${c3p0.acquireretryattempts}"/>
 </bean>
 
 <!--配置sqlsessionfactory-->
 <bean id="sqlsessionfactory" class="org.mybatis.spring.sqlsessionfactorybean">
  <property name="datasource" ref="datasource"/>
  <!--扫描model包,使用别名-->
  <property name="typealiasespackage" value="com.kevin.hrsystem.model"/>
  <property name="mapperlocations" value="classpath:mapper/*.xml"/>
 </bean>
 
 <!--配置扫描dao接口包,动态实现dao接口,注入到spring容器中-->
 <bean class="org.mybatis.spring.mapper.mapperscannerconfigurer">
  <property name="sqlsessionfactorybeanname" value="sqlsessionfactory"/>
  <property name="basepackage" value="com.kevin.hrsystem.dao"/>
 </bean>
 
 <!--配置事务管理器-->
 <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager">
  <!--注入数据库连接池-->
  <property name="datasource" ref="datasource"/>
 </bean>
 
 <tx:annotation-driven transaction-manager="transactionmanager"/>
 
</beans>

根据上面的配置文件可以看出,我们的dao层实现类是放在了classpath:mapper路径下面的,这里我们一样只给出employeedao组件的实现,

<?xml version="1.0" encoding="utf-8"?>
<!doctype mapper public "-//mybatis.org//dtd mapper 3.0//en" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 
<mapper namespace="com.kevin.hrsystem.dao.employeedao">
 <insert id="save" parametertype="employee" usegeneratedkeys="true" keyproperty="id">
  insert into employee_inf(emp_type, emp_name, emp_pass, emp_salary, mgr_id, dept_name) values (#{type}, #{name}, #{password}, #{salary}, #{manager.id}, #{departmentname})
 </insert>
 
 <insert id="saveasemployee" parametertype="employee" usegeneratedkeys="true" keyproperty="id">
  insert into employee_inf(emp_type, emp_name, emp_pass, emp_salary, mgr_id) values (#{type}, #{name}, #{password}, #{salary}, #{manager.id})
 </insert>
 
 <insert id="saveasmanager" parametertype="manager" usegeneratedkeys="true" keyproperty="id">
  insert into employee_inf(emp_type, emp_name, emp_pass, emp_salary, dept_name) values (#{type}, #{name}, #{password}, #{salary}, #{departmentname})
 </insert>
 
 
 <delete id="delete" parametertype="long">
  delete from employee_inf where emp_id=#{id}
 </delete>
 
 <update id="update" parametertype="employee">
  update employee_inf set emp_name=#{name}, emp_pass=#{password}, emp_salary=#{saraly}, emp_type=#{type}, mgr_id=#{manager.id} where emp_id=#{id}
 </update>
 
 <!--查询语句 start-->
 
 <select id="findall" resultmap="employeeresultmap">
  select * from employee_inf
 </select>
 
 <select id="findbyid" parametertype="long" resultmap="employeeresultmap">
  select * from employee_inf where emp_id=#{id}
 </select>
 
 <select id="findbynameandpass" resultmap="employeeresultmap">
  select * from employee_inf where emp_name=#{name} and emp_pass=#{password}
 </select>
 
 <select id="findbyname" resultmap="employeeresultmap">
  select * from employee_inf where emp_name=#{name}
 </select>
 
 <!--根据mgr_id查找员工-->
 <select id="findemployeesbymgrid" parametertype="long" resultmap="employeeresultmap">
  select * from employee_inf where mgr_id=#{id}
 </select>
 
 <!--查询语句 end -->
 
 <!-- resultmap设置,使用鉴别器来区分employee和manager-->
 <resultmap id ="employeeresultmap" type="com.kevin.hrsystem.model.employee">
  <id property="id" column="emp_id"/>
  <result property="type" column="emp_type"/>
  <result property="name" column="emp_name"/>
  <result property="password" column="emp_pass"/>
  <result property="salary" column="emp_salary"/>
  <discriminator javatype="int" column="emp_type">
   <case value="1" resultmap="originalemployeeresultmap"/>
   <case value="2" resultmap="managerresultmap"/>
  </discriminator>
 </resultmap>
 
 
 <resultmap id="originalemployeeresultmap" type="com.kevin.hrsystem.model.employee" extends="employeeresultmap">
  <association property="manager" javatype="com.kevin.hrsystem.model.manager">
   <id property="id" column="mgr_id"/>
  </association>
 </resultmap>
 
 <resultmap id="managerresultmap" type="com.kevin.hrsystem.model.manager" extends="employeeresultmap">
  <result property="departmentname" column="dept_name"/>
  <collection property="employees" column="emp_id" oftype="com.kevin.hrsystem.model.employee" select="com.kevin.hrsystem.dao.employeedao.findemployeesbymgrid"/>
 </resultmap>
 
 <!--基础resultmap end-->
 
 
 <select id="selectbyidwithforeign" parametertype="long" resultmap="employeewithforeignresultmap">
  select e.emp_id, e.emp_name, e.emp_pass, e.emp_type, e.emp_salary, m.emp_id mgr_id, m.emp_name mgr_name, m.dept_name from employee_inf e, employee_inf m where e.mgr_id = m.emp_id and e.emp_id = #{id}
 </select>
 
 <resultmap id ="employeewithforeignresultmap" type="com.kevin.hrsystem.model.employee">
  <id property="id" column="emp_id"/>
  <result property="type" column="emp_type"/>
  <result property="name" column="emp_name"/>
  <result property="password" column="emp_pass"/>
  <result property="salary" column="emp_salary"/>
  <association property="manager" javatype="com.kevin.hrsystem.model.manager">
   <id property="id" column="mgr_id"/>
   <result property="name" column="mgr_name"/>
   <result property="departmentname" column="dept_name"/>
  </association>
 </resultmap>
 
</mapper>

这个xml文件就是我们employeedao组件的实现类了。关于这个类的鉴别器使用可以参考 ssm项目问题与解决(还没有出) 

四,service层

1)业务逻辑组件的设计

业务逻辑组件是dao组件的门面,所以可以理解为业务逻辑组件需要依赖于dao组件。empmanagerservice接口(业务逻辑组件之一)里定义了大量的业务方法,这些方法的实现依赖于dao组件,由于每个业务都要涉及多个dao操作,其dao操作是单条数据记录的操作,而业务逻辑方法的访问,则需要设计多个dao操作,因此每个业务逻辑方法可能需要涉及多条记录的访问

业务逻辑组件面向dao接口编程,可以让业务逻辑组件从dao组件的实现中分离,因此业务逻辑组件只关系业务逻辑的实现,无须关心数据访问逻辑的实现

empmanagerservice接口的代码实现如下:

package com.kevin.hrsystem.service;
 
import com.kevin.hrsystem.model.attendtype;
import com.kevin.hrsystem.model.employee;
import com.kevin.hrsystem.model.manager;
import com.kevin.hrsystem.vo.attendvo;
import com.kevin.hrsystem.vo.paymentvo;
 
import java.util.list;
 
public interface empmanagerservice {
 
 /**
  * 验证登录
  * @param employee 登录的身份
  * @return
  * 登录后的身份确认:0为登录失败,1为登录emp,2为登录mgr
  */
 int validlogin(employee employee);
 
 
 /**
  * 自动打卡,周一到周五,早上7点为每个员工插入旷工记录
  */
 void autopunch();
 
 /**
  * 自动结算工资,每月1号,结算上个月工资
  */
 void autopay();
 
 /**
  * 验证某个员工是否可以打卡,以及打卡的类型,上班打卡,还是下班打卡
  * @param user 员工名
  * @param dutyday 日期
  * @return 可打卡的类别
  */
 int validpunch(string user, string dutyday);
 
 
 /**
  * 实现普通员工的打卡
  * @param user 员工名
  * @param dutyday 打卡日期
  * @param iscome 是否是上班打卡
  * @return 打卡结果
  */
 int punch(string user, string dutyday, boolean iscome);
 
 /**
  * 根据员工浏览自己的工资
  * @param employeename 员工名
  * @return 该员工的工资列表
  */
 list<paymentvo> employeesalary(string employeename);
 
 
 /**
  * 员工查看自己的最近三天的非正常打卡
  * @param employeename 员工名
  * @return 该员工最近三天的非正常打卡
  */
 list<attendvo> getunattend(string employeename);
 
 
 /**
  * 返回全部的出勤类别
  * @return 全部的出勤类别
  */
 list<attendtype> getalltype();
 
 /**
  * 添加申请
  * @param attid 申请的出勤id
  * @param typeid 申请的类型id
  * @param reason 申请的理由
  * @return 添加的结果
  */
 boolean addapplication(int attid, int typeid, string reason);
 
}

2)实现业务逻辑组件

业务逻辑组件负责实现系统所需的业务方法,系统有多少个业务需求,业务逻辑组件就提供多少个对应方法,本应用采用的贫血模式的架构模型,因此业务逻辑方法完全由业务逻辑组件负责实现。

业务逻辑组件只负责业务逻辑上的变化,而持久层的变化则交给dao层负责,因此业务逻辑组件必须依赖于dao组件。

下面是empmanagerserviceimpl的代码实现:

package com.kevin.hrsystem.service.impl;
 
import com.kevin.hrsystem.dao.*;
import com.kevin.hrsystem.model.*;
import com.kevin.hrsystem.service.empmanagerservice;
import com.kevin.hrsystem.vo.attendvo;
import com.kevin.hrsystem.vo.paymentvo;
import org.springframework.beans.factory.annotation.autowired;
import org.springframework.stereotype.service;
 
import javax.annotation.resource;
import java.text.simpledateformat;
import java.util.arraylist;
import java.util.calendar;
import java.util.date;
import java.util.list;
 
import static com.kevin.hrsystem.constant.constantmanager.*;
 
@service("empmanagerservice")
public class empmanagerserviceimpl implements empmanagerservice {
 @resource
 private applicationdao applicationdao;
 @resource
 private attenddao attenddao;
 @resource
 private attendtypedao attendtypedao;
 @resource
 private checkbackdao checkbackdao;
 @resource
 private employeedao employeedao;
 @resource
 private paymentdao paymentdao;
 
 public int validlogin(employee employee) {
 
  employee employee1 = employeedao.findbynameandpass(employee.getname(), employee.getpassword());
  if(null != employee1) {
   if(employee1 instanceof manager) {
    system.out.println("empmanagerservice: manager");
    system.out.println(employee);
    return login_mgr;
   } else {
    system.out.println("empmanagerservice:employee");
    system.out.println(employee);
    return login_emp;
   }
  }
 
  return login_falt;
 }
 
 public void autopunch() {
  list<employee> employees = employeedao.findall();
  system.out.println(employees.size());
  //获取当前时间
  string dutyday = new java.sql.date(system.currenttimemillis()).tostring();
  for(employee employee : employees) {
   system.out.println(employee);
   //先设置出勤类型为旷工,然后真正出勤的时候由员工去修改出勤的状态
   //6表示旷工;已经插入数据库了; 这里最好弄一个常量管理类;但为了方便先这样吧
   attendtype attendtype = attendtypedao.findbyid(6);
   attend a = new attend();
   a.setattendtype(attendtype);
   a.setdutyday(dutyday);
   //如果是早上,则对应上班打卡
   if(calendar.getinstance().get(calendar.hour_of_day) < am_limit) {
    a.setcome(true);
   } else {
    //下班打卡
    a.setcome(false);
   }
   a.setemployee(employee);
   attenddao.save(a);
  }
 }
 
 public void autopay() {
  list<employee> employees = employeedao.findall();
  //获取上个月时间
  calendar c = calendar.getinstance();
  c.add(calendar.day_of_month, -15);
  simpledateformat sdf = new simpledateformat("yyyy-mm");
  string paymonth = sdf.format(c.gettime());
 
  for(employee employee : employees) {
   payment pay = new payment();
   double amount = employee.getsalary();
   //获取出勤记录
   list<attend> attends = attenddao.findbyempandmonth(employee, paymonth);
   //计算工资
   for(attend attend : attends) {
    amount += attend.getattendtype().getamerceamount();
   }
   pay.setpaymonth(paymonth);
   pay.setemployee(employee);
   pay.setpayamount(amount);
   paymentdao.save(pay);
  }
 
 }
 
 @override
 public int validpunch(string user, string dutyday) {
  //不能查找到对应的用户,返回无法打卡
  employee employee = employeedao.findbyname(user);
  if(null == employee) {
   return no_punch;
  }
  //打到员工指定日期的出勤记录
  list<attend> attends = attenddao.findbyempanddutyday(employee, dutyday);
  //系统没有为用户在当前插入空打卡记录,无法打卡
  if(null == attends || attends.size() == 0) {
   return no_punch;
  }
 
  //开始上班打卡
  if(attends.size() == 1 && attends.get(0).iscome() && null == attends.get(0).getpunchtime()) {
   return come_punch;
  }
  if(attends.size() == 1 && null == attends.get(0).getpunchtime()) {
   return leave_punch;
  }
  if(attends.size() == 2) {
   if(null == attends.get(0).getpunchtime() && null == attends.get(0).getpunchtime()) {
    return both_punch;
   } else if(null == attends.get(1).getpunchtime()) {
    return leave_punch;
   } else {
    return no_punch;
   }
  }
  return no_punch;
 }
 
 public int punch(string user, string dutyday, boolean iscome) {
  employee employee = employeedao.findbyname(user);
  if(null == employee) {
   return punch_falt;
  }
 
  //找到员工本次打卡对应的出勤记录
  attend attend = attenddao.findbyempanddutydayandcome(employee, dutyday, iscome);
  if(null == attend) {
   return punch_falt;
  }
  //如果已经打卡
  if(null != attend.getpunchtime()) {
   return punched;
  }
 
  int punchhour = calendar.getinstance().get(calendar.hour_of_day);
  attend.setpunchtime(new date());
  //上班打卡
  if(iscome) {
   //9点之前算正常
   if(punchhour < come_limit) {
    //1表示正常
    attend.setattendtype(attendtypedao.findbyid(1));
   } else if (punchhour < late_limit) {
    //9点到11点之间算迟到
    attend.setattendtype(attendtypedao.findbyid(4));
   }
   //11点之后算旷工,不用管,本来初始就是旷工
  } else {
   //下班打卡
   //18点之后算正常
   if(punchhour >= leave_limit) {
    attend.setattendtype(attendtypedao.findbyid(1));
   } else if(punchhour >= leave_limit) {
    //16到18点算正常
    attend.setattendtype(attendtypedao.findbyid(5));
   }
  }
  attenddao.update(attend);
  return punch_succ;
 }
 
 public list<paymentvo> employeesalary(string employeename) {
  employee employee = employeedao.findbyname(employeename);
 
  list<payment> payments = paymentdao.findbyemp(employee);
  system.out.println(payments);
 
  list<paymentvo> result = new arraylist<paymentvo>();
 
  for(payment payment : payments) {
   result.add(new paymentvo(payment.getpaymonth(), payment.getpayamount()));
  }
  return result;
 }
 
 /**
  * 查看自己最近三天的非正常打卡
  * @param employeename 员工名
  * @return 该员工的最近三天的非正常打卡
  */
 public list<attendvo> getunattend(string employeename) {
  attendtype type = attendtypedao.findbyid(1);
  employee employee = employeedao.findbyname(employeename);
 
  //获取最近三天非正常的出勤记录
  list<attend> attends = attenddao.findbyempunattend(employee, type);
  list<attendvo> result = new arraylist<attendvo>();
  for(attend attend : attends) {
   result.add(new attendvo(attend.getid(), attend.getdutyday(), attend.getattendtype().gettypename(), attend.getpunchtime()));
  }
  return result;
 
 }
 
 public list<attendtype> getalltype() {
  return attendtypedao.findall();
 }
 
 @override
 public boolean addapplication(int attid, int typeid, string reason) {
  application application = new application();
  //获取申请需要改变的出勤记录
  attend attend = attenddao.findbyid(attid);
  attendtype type = attendtypedao.findbyid(typeid);
  application.setattend(attend);
  application.setattendtype(type);
  if(reason != null) {
   application.setapplicationreason(reason);
  }
  applicationdao.save(application);
  return true;
 }
}

这里需要介绍一下上面业务逻辑组件的一些方法,首先是autopunch和autopay,这两个方法并不由客户端直接调用,而是由任务调度来执行.

系统会在每个工作日的早上7点和下午12点时自动调用autopunch,这个方法负责为每个员工插入一条旷工考勤记录,所以一天就会插入两条旷工记录了。这样做的原因在于,先插入记录为旷工,然后在员工上班打卡时,就将早上7点插入的记录的出勤类型根据出勤时间进行修改为正常或是迟到等,如果没有打卡就是旷工了。在员工下班打卡的时候,根据下班打卡的时间将12点插入的记录进行修改其出勤类型。

系统同样会在每月3日为所有员工完成工资结算,这个是通过autopay来实现的。

六,实现任务的自动调度

系统中常常有些需要自动执行的任务,这些任务可能每隔一段时间就要执行一次,也可能需要在指定时间点自动执行,这些任务的自动执行必须使用任务的自动调度。通过使用开源框架quartz,借助于它的支持,既可以实现简单的任务调度,也可以实现复杂的任务调度。

1)引入quartz

为了在spring项目中引入quartz, 我们需要在pom.xml中加入如下的包依赖,

 <dependency>
  <groupid>org.springframework</groupid>
  <artifactid>spring-context-support</artifactid>
  <version>${spring.version}</version>
 </dependency>
 
  <!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
 <dependency>
  <groupid>org.quartz-scheduler</groupid>
  <artifactid>quartz</artifactid>
  <version>2.2.1</version>
 </dependency>

2)实现任务调度

quartz允许提供一个名为quartz.properties的配置文件,通过该配置文件,可以修改框架运行时的环境,其配置如下:

# 配置主调度器属性
org.quartz.scheduler.instancename = quartzscheduler
org.quartz.scheduler.instanceid = auto
# 配置线程池
# quartz线程池的实现类
org.quartz.threadpool.class = org.quartz.simpl.simplethreadpool
# 线程池的线程数量
org.quartz.threadpool.threadcount = 1
# 线程池里线程的优先级
org.quartz.threadpool.threadpriority = 10
# 配置作业存储
org.quartz.jobstore.misfirethreshold = 60000
org.quartz.jobstore.class = org.quartz.simpl.ramjobstore

接下来就实现我们的两个作业类了,这两个作业类都需要去继承quartzjobbean,punchjob的实现如下:

package com.kevin.hrsystem.schedule;
import com.kevin.hrsystem.service.empmanagerservice;
import org.quartz.jobexecutioncontext;
import org.quartz.jobexecutionexception;
import org.springframework.scheduling.quartz.quartzjobbean;
 
import javax.annotation.resource;
 
public class punchjob extends quartzjobbean {
 //判断作业是否执行的标志
 private boolean isrunning = false;
 
 @resource
 private empmanagerservice empmanagerservice;
 
 public void setempmanagerservice(empmanagerservice empmanagerservice) {
  this.empmanagerservice = empmanagerservice;
 }
 
 public void executeinternal(jobexecutioncontext ctx) throws jobexecutionexception {
  if(!isrunning) {
   system.out.println("开始调度自动打卡");
   isrunning = true;
   empmanagerservice.autopunch();
   system.out.println("打卡结束");
   isrunning = false;
  }
 }
}

定义完上面的工作类后,就可以在配置文件中进行定义bean了,新建一个spring-quartz.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:p="http://www.springframework.org/schema/p"
  xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
 <!--croexpression指定cron表达式:每月3日2时启动-->
 <bean id="crontriggerpay"
   class="org.springframework.scheduling.quartz.crontriggerfactorybean"
   p:cronexpression="0 0 2 3 * ? *">
  <property name="jobdetail">
   <!--使用嵌套bean的方法来定义任务bean,jobclass指定任务bean的实现类-->
   <bean class="org.springframework.scheduling.quartz.jobdetailfactorybean" p:jobclass="com.kevin.hrsystem.schedule.payjob" p:durability="true" >
    <property name="jobdataasmap">
     <map>
      <entry key="empmanagerservice" value-ref="empmanagerservice"/>
     </map>
    </property>
   </bean>
  </property>
 </bean>
 
 <!--定义触发器来管理任务 bean cronexpression指定cron表达式: 周一到周五7点和12点执行调度-->
 <bean id="crontriggerpunch" class="org.springframework.scheduling.quartz.crontriggerfactorybean" p:cronexpression="0 0 7,12 ? * mon-fri">
  <property name="jobdetail">
   <bean class="org.springframework.scheduling.quartz.jobdetailfactorybean" p:jobclass="com.kevin.hrsystem.schedule.punchjob" p:durability="true">
    <property name="jobdataasmap">
     <map>
      <entry key="empmanagerservice" value-ref="empmanagerservice"/>
     </map>
    </property>
   </bean>
 
  </property>
 </bean>
 
 <!--执行实际的调度-->
 <bean class="org.springframework.scheduling.quartz.schedulerfactorybean">
  <property name="triggers">
   <list>
    <ref bean="crontriggerpay"/>
    <ref bean="crontriggerpunch"/>
   </list>
  </property>
 </bean>
 
</beans>

关于cron表达式的使用请自行google,其配置还是比较直观的。 

七, 实现系统web层

在这一层,我们使用的是springmvc,在初始项目中,已经配置好了相关的文件,主要是配置下spring-mvc.xml和web.xml,两个文件的配置如下:

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:mvc="http://www.springframework.org/schema/mvc"
  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/mvc
  http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
 
 <!-- 扫描web相关的bean -->
 <context:component-scan base-package="com.kevin.hrsystem.controller"/>
 
 <!-- 开启springmvc注解模式 -->
 <mvc:annotation-driven/>
 
 <!-- 静态资源默认servlet配置 -->
 <mvc:default-servlet-handler/>
 
 <!-- 配置jsp 显示viewresolver -->
 <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">
  <property name="viewclass" value="org.springframework.web.servlet.view.jstlview"/>
  <property name="prefix" value="/web-inf/views/"/>
  <property name="suffix" value=".jsp"/>
 </bean>
</beans>

web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
   xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee
 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
 
 <display-name>archetype created web application</display-name>
 
 <!--编码过滤器-->
 <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>
 </filter>
 <filter-mapping>
 <filter-name>encodingfilter</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>
 
 <!--配置springmvc中心控制器 dispatcherservlet-->
 <!-- 配置dispatcherservlet -->
 <servlet>
 <servlet-name>springmvc</servlet-name>
 <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>
 <!-- 配置springmvc需要加载的配置文件-->
 <init-param>
  <param-name>contextconfiglocation</param-name>
  <param-value>classpath:spring-*.xml</param-value>
 </init-param>
 <load-on-startup>1</load-on-startup>
 <!--<async-supported>true</async-supported>-->
 </servlet>
 <servlet-mapping>
 <servlet-name>springmvc</servlet-name>
 <!-- 匹配所有请求,此处也可以配置成 *.do 形式 -->
 <url-pattern>/</url-pattern>
 </servlet-mapping>
 
 <welcome-file-list>
 <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 
</web-app>

配置好上面的文件之后,我们的所有请求就会被springmvc所拦截进行分发了。为了节约篇幅,我们这里只陈述实现登录业务的整体过程,其他的业务大致类似。

因为到service层我们都已经实现了,只要定义好前端和controller层的数据就可以了,我们先开发jsp页面。在这里有一个要注意的,在tomcat项目中,放在应用程序目录下的任何资源,用户都可以通过输入该资源的url而直接进行访问,如果你希望某个资源可以被servlet访问,但是不能被用户访问,那么应用把它放在web-inf目录下面; 所以我们的jsp页面是放在webapp/web-inf下面的,而图片等静态资源是放在了webapp/resources下。

为了在我们的jsp中使用jstl,我们还需要引入如下的依赖

 <dependency>
  <groupid>javax.servlet</groupid>
  <artifactid>jstl</artifactid>
  <version>1.2</version>
 </dependency>
 
 <dependency>
  <groupid>taglibs</groupid>
  <artifactid>standard</artifactid>
  <version>1.1.2</version>
 </dependency>

首先们来看下main.jsp的源码,当index.jsp被访问时(欢迎页面),请求就会被转发到这个页面

<%--
 created by intellij idea.
 user: kevin
 date: 18-3-3
 time: 下午5:34
 to change this template use file | settings | file templates.
--%>
<%@ page contenttype="text/html;charset=utf-8" language="java" %>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <title>java ee简单工作流系统</title>
</head>
<body>
<%@include file="header.jsp"%>
<table width="960" align="center"
  background="${pagecontext.request.contextpath}/resources/images/bodybg.jpg">
 <tr>
  <td colspan="3">请单击后面链接开始使用系统<a href="loginpage" rel="external nofollow" >登录系统</a></td>
 </tr>
 <tr>
  <td colspan="3">
   <br>
   <p align="center"><span class="pt11">这仅仅是一个java ee的框架程序。应用模拟一个简单的工作流系统。系统包含两个角色,<br>
 普通员工的功能包括员工出勤打卡,员工的人事异动申请,员工查看工资单。<br>
 经理的功能包括管理部门员工,签核申请,每月工资自动结算等。</span></p>
   <p align="center" class="pt11">应用模拟了简单的工作流,使用的轻量级java ee架构。技术包括:struts 2.3、spring 4.0、hibernate 4.3、quartz 2.2,整个应用使用spring提供的dao支持操作数据库,同时利用spring的声明式事务。<br>
    程序中的权限检查使用spring的aop框架支持,也利用了spring的任务调度抽象<br>
    hibernate为底层的数据库访问提供支持,作为o/r mapping框架使用。</p>
   <p align="center" class="pt11">本程序的源代码随程序一起发布,版权属于李刚,<a href="http://www.crazyit.org" rel="external nofollow" >http://www.crazyit.org</a><br>
    任何个人可用来参考学习java ee架构,规范,但请勿在本程序的基础上修改,用做任何商业用途。<br>
    本人保留依法追究相关责任的权利。转载和学习请保留此信息。
    <br>
   </p>
  </td>
 </tr>
</table>
<%@include file="footer.jsp"%>
</body>
</html>

所以当我们点击了登录系统按钮之后,就会发起/loginpage的请求,我们需要定义这个方法,其定义如下(在commoncontroller.java中):

 @requestmapping(value = "/loginpage", method = requestmethod.get)
 public modelandview showloginpage() {
  return new modelandview("login", "employee", new employee());
 }

关于springmvc的基本使用可以参考:

通过上面的逻辑我们知道,我们的springmvc经过处理请求后,会发送login.jsp给前端,login.jsp的定义如下:

<%--
 created by intellij idea.
 user: kevin
 date: 18-3-3
 time: 下午5:55
 to change this template use file | settings | file templates.
--%>
<%@ page contenttype="text/html;charset=utf-8" language="java" %>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
 <meta http-equiv="content-type" content="text/html;charset=utf-8">
 <title>登录系统</title>
</head>
 
<body>
 <%@include file="header.jsp"%>
 <table width="960" align="center"
   background="${pagecontext.request.contextpath}/resources/images/bodybg.jpg">
  <tr>
   <td>
    请输入用户名和密码来登录<br />
    <c:if test="${error.length() > 0}">
     <div class="error">
       <c:out value="${error}"></c:out>
     </div>
    </c:if>
    <div class="center">
     <form:form method="post" action="processlogin" modelattribute="employee">
      <table>
       <tr>
        <td><form:label path="name">name</form:label></td>
        <td><form:input path="name"/></td>
       </tr>
       <tr>
        <td><form:label path="password">password</form:label></td>
        <td><form:password path="password"/></td>
       </tr>
       <tr>
        <td><input type="submit" value="登录"></td>
        <td><input type="reset" value="重填"></td>
       </tr>
      </table>
     </form:form>
    </div>
   </td>
  </tr>
 </table>
<%@include file="footer.jsp"%>
 
</body>
</html>

当我们输入用户名和密码,并点击登录之后,会发起/processlogin的请求,其定义如下:

@requestmapping(value = "/processlogin", method = requestmethod.post)
 public modelandview processlogin(@modelattribute("employee") employee employee, httpservletrequest request) {
  system.out.println(employee);
  system.out.println(request.getprotocol());
  modelandview modelandview;
  int result = empmanagerservice.validlogin(employee);
  string message;
  //登录结果为普通员工
  system.out.println(result);
  if(result == constantmanager.login_emp) {
   //设置session
   request.getsession().setattribute(webconstant.user, employee.getname());
   request.getsession().setattribute(webconstant.level, webconstant.emp_level);
 
   message = "您已成功登录系统,您的身份是普通员工";
   system.out.println(message);
//   modelandview = new modelandview("success");
   modelandview = new modelandview("employee/index");
   modelandview.addobject("message", message);
   return modelandview;
  } else if(result == constantmanager.login_mgr){
   request.getsession().setattribute(webconstant.user, employee.getname());
   request.getsession().setattribute(webconstant.level, webconstant.mgr_level);
 
   message = "您已成功登录系统,您的身份是经理";
   system.out.println(message);
//   modelandview = new modelandview("success");
   modelandview = new modelandview("manager/index");
   modelandview.addobject("message", message);
   return modelandview;
  } else {
   message = "用户名与密码不匹配,登录失败";
   system.out.println(message);
   modelandview = new modelandview("error");
   modelandview.addobject("message", message);
   return modelandview;
  }
 }

根据校验结果的不同,而有不同的返回页面,假设校验成功是一个普通员工的话,我们就返回了employee/index.jsp,并设置了message变量供jsp页面获取,employee/index.jsp如下:

<%--
 created by intellij idea.
 user: kevin
 date: 18-3-6
 time: 下午4:36
 to change this template use file | settings | file templates.
--%>
<%@ page contenttype="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <title>员工首页</title>
</head>
<body>
 <%@include file="../header.jsp"%>
 <%@include file="empheader.jsp"%>
 <table width="960" align="center" background="${pagecontext.request.contextpath}/resources/images/bodybg.jpg">
  <tr height="60">
   <td> </td>
  </tr>
  <tr>
   <td>
    <c:if test="${message.length()>0}">
     <div class="error">
      <c:out value="${message}"></c:out>
     </div>
    </c:if>
   </td>
  </tr>
  <tr height="80">
   <td> </td>
  </tr>
  <tr>
   <td><%=request.getsession().getattribute("user")%>
    ,欢迎您使用javaee简单工作流系统,您是普通员工</td>
  </tr>
  <tr height="60">
   <td> </td>
  </tr>
 </table>
<%@include file="../footer.jsp"%>
</body>
</html>

其他页面的开发逻辑也类似如上。

八,结语

项目是依据《轻量级java ee企业应用实战 第4版》的ssh项目来实现的,所以可能在实现过程中会有些问题,如果有问题,欢迎留言讨论。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网