SSM-CRUD员工管理项目
一,项目环境
JDK-1.8
IDEA-2017
MySq-l5.7
Maven-3.5
Tomcat- 9.0
二,数据库设计
CREATE DATABASE `ssmstaff`;
USE `ssmstaff`;
DROP TABLE IF EXISTS `Staff`;
CREATE TABLE `Staff` (
`staffID` INT(10) NOT NULL AUTO_INCREMENT COMMENT '员工id',
`staffName` VARCHAR(100) NOT NULL COMMENT '员工名字',
`staffAge` INT(11) NOT NULL COMMENT '员工年龄',
`staffAddress` VARCHAR(200) NOT NULL COMMENT '员工地址',
KEY `staffID` (`staffID`)
) ENGINE=INNODB DEFAULT CHARSET=utf8
INSERT INTO `Staff`(`staffID`,`staffName`,`staffAge`,`staffAddress`)VALUES
(1,'张无忌',20,'上海'),
(2,'周芷若',18,'北京'),
(3,'赵敏',18,'香港');
三,基本环境搭建
3.1 新建一个maven项目
3.2 到pom.xml文件所需要的坐标
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
3.3 资源过滤
<build>
<!--设置maven资源过滤-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
3.4 创建所需的文件夹
每一个对应的内容为
controller---->StaffController:
package com.duan.controller;
import com.duan.domain.Staff;
import com.duan.service.staffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.ArrayList;
import java.util.List;
//
@SuppressWarnings("all")
@Controller
@RequestMapping("/staff")
public class StaffController {
@Autowired
@Qualifier("staffServiceImpl")
private staffService staffservice;
@RequestMapping(