SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

SSM项目

界面效果
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
源代码下载:https://download.csdn.net/download/qq_44757034/16604945

一、开发环境

IDE:Eclipse
JDK:1.8
数据库:MySQL

二、创建数据库

1、搭建数据库,以下是数据库的代码,将数据库导入到你的MySQL当中

/*
Navicat MySQL Data Transfer

Source Server         : localhost_3306
Source Server Version : 50611
Source Host           : localhost:3306
Source Database       : crm

Target Server Type    : MYSQL
Target Server Version : 50611
File Encoding         : 65001

Date: 2016-05-12 00:07:42
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for base_dict
-- ----------------------------
DROP TABLE IF EXISTS `base_dict`;
CREATE TABLE `base_dict` (
  `dict_id` varchar(32) NOT NULL COMMENT '数据字典id(主键)',
  `dict_type_code` varchar(10) NOT NULL COMMENT '数据字典类别代码',
  `dict_type_name` varchar(64) NOT NULL COMMENT '数据字典类别名称',
  `dict_item_name` varchar(64) NOT NULL COMMENT '数据字典项目名称',
  `dict_item_code` varchar(10) DEFAULT NULL COMMENT '数据字典项目代码(可为空)',
  `dict_sort` int(10) DEFAULT NULL COMMENT '排序字段',
  `dict_enable` char(1) NOT NULL COMMENT '1:使用 0:停用',
  `dict_memo` varchar(64) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`dict_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of base_dict
-- ----------------------------
INSERT INTO `base_dict` VALUES ('1', '001', '客户行业', '教育培训 ', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('10', '003', '公司性质', '民企', null, '3', '1', null);
INSERT INTO `base_dict` VALUES ('12', '004', '年营业额', '1-10万', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('13', '004', '年营业额', '10-20万', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('14', '004', '年营业额', '20-50万', null, '3', '1', null);
INSERT INTO `base_dict` VALUES ('15', '004', '年营业额', '50-100万', null, '4', '1', null);
INSERT INTO `base_dict` VALUES ('16', '004', '年营业额', '100-500万', null, '5', '1', null);
INSERT INTO `base_dict` VALUES ('17', '004', '年营业额', '500-1000万', null, '6', '1', null);
INSERT INTO `base_dict` VALUES ('18', '005', '客户状态', '基础客户', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('19', '005', '客户状态', '潜在客户', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('2', '001', '客户行业', '电子商务', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('20', '005', '客户状态', '成功客户', null, '3', '1', null);
INSERT INTO `base_dict` VALUES ('21', '005', '客户状态', '无效客户', null, '4', '1', null);
INSERT INTO `base_dict` VALUES ('22', '006', '客户级别', '普通客户', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('23', '006', '客户级别', 'VIP客户', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('24', '007', '商机状态', '意向客户', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('25', '007', '商机状态', '初步沟通', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('26', '007', '商机状态', '深度沟通', null, '3', '1', null);
INSERT INTO `base_dict` VALUES ('27', '007', '商机状态', '签订合同', null, '4', '1', null);
INSERT INTO `base_dict` VALUES ('3', '001', '客户行业', '对外贸易', null, '3', '1', null);
INSERT INTO `base_dict` VALUES ('30', '008', '商机类型', '新业务', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('31', '008', '商机类型', '现有业务', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('32', '009', '商机来源', '电话营销', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('33', '009', '商机来源', '网络营销', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('34', '009', '商机来源', '推广活动', null, '3', '1', null);
INSERT INTO `base_dict` VALUES ('4', '001', '客户行业', '酒店旅游', null, '4', '1', null);
INSERT INTO `base_dict` VALUES ('5', '001', '客户行业', '房地产', null, '5', '1', null);
INSERT INTO `base_dict` VALUES ('6', '002', '客户信息来源', '电话营销', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('7', '002', '客户信息来源', '网络营销', null, '2', '1', null);
INSERT INTO `base_dict` VALUES ('8', '003', '公司性质', '合资', null, '1', '1', null);
INSERT INTO `base_dict` VALUES ('9', '003', '公司性质', '国企', null, '2', '1', null);

-- ----------------------------
-- Table structure for customer
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
  `cust_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT '客户编号(主键)',
  `cust_name` varchar(32) NOT NULL COMMENT '客户名称(公司名称)',
  `cust_user_id` bigint(32) DEFAULT NULL COMMENT '负责人id',
  `cust_create_id` bigint(32) DEFAULT NULL COMMENT '创建人id',
  `cust_source` varchar(32) DEFAULT NULL COMMENT '客户信息来源',
  `cust_industry` varchar(32) DEFAULT NULL COMMENT '客户所属行业',
  `cust_level` varchar(32) DEFAULT NULL COMMENT '客户级别',
  `cust_linkman` varchar(64) DEFAULT NULL COMMENT '联系人',
  `cust_phone` varchar(64) DEFAULT NULL COMMENT '固定电话',
  `cust_mobile` varchar(16) DEFAULT NULL COMMENT '移动电话',
  `cust_zipcode` varchar(10) DEFAULT NULL,
  `cust_address` varchar(100) DEFAULT NULL,
  `cust_createtime` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`cust_id`),
  KEY `FK_cst_customer_source` (`cust_source`),
  KEY `FK_cst_customer_industry` (`cust_industry`),
  KEY `FK_cst_customer_level` (`cust_level`),
  KEY `FK_cst_customer_user_id` (`cust_user_id`),
  KEY `FK_cst_customer_create_id` (`cust_create_id`)
) ENGINE=InnoDB AUTO_INCREMENT=162 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of customer
-- ----------------------------
INSERT INTO `customer` VALUES ('14', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:01');
INSERT INTO `customer` VALUES ('15', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:01');
INSERT INTO `customer` VALUES ('16', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:01');
INSERT INTO `customer` VALUES ('17', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:02');
INSERT INTO `customer` VALUES ('22', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:03');
INSERT INTO `customer` VALUES ('24', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:03');
INSERT INTO `customer` VALUES ('25', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:03');
INSERT INTO `customer` VALUES ('26', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:03');
INSERT INTO `customer` VALUES ('28', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:04');
INSERT INTO `customer` VALUES ('29', '令狐冲', null, null, '7', '1', '23', '任盈盈', '0108888886', '13888888886', '6123456', '北京三里桥6', '2016-04-08 16:32:04');
INSERT INTO `customer` VALUES ('30', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:04');
INSERT INTO `customer` VALUES ('31', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:04');
INSERT INTO `customer` VALUES ('33', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:04');
INSERT INTO `customer` VALUES ('34', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:05');
INSERT INTO `customer` VALUES ('35', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:05');
INSERT INTO `customer` VALUES ('36', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:05');
INSERT INTO `customer` VALUES ('37', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:05');
INSERT INTO `customer` VALUES ('38', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:05');
INSERT INTO `customer` VALUES ('39', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:06');
INSERT INTO `customer` VALUES ('40', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:06');
INSERT INTO `customer` VALUES ('41', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:06');
INSERT INTO `customer` VALUES ('42', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:06');
INSERT INTO `customer` VALUES ('43', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:06');
INSERT INTO `customer` VALUES ('44', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:07');
INSERT INTO `customer` VALUES ('45', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:07');
INSERT INTO `customer` VALUES ('46', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:07');
INSERT INTO `customer` VALUES ('47', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:07');
INSERT INTO `customer` VALUES ('48', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:07');
INSERT INTO `customer` VALUES ('49', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:07');
INSERT INTO `customer` VALUES ('50', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:08');
INSERT INTO `customer` VALUES ('51', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:08');
INSERT INTO `customer` VALUES ('52', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:08');
INSERT INTO `customer` VALUES ('53', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:08');
INSERT INTO `customer` VALUES ('54', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:08');
INSERT INTO `customer` VALUES ('55', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:08');
INSERT INTO `customer` VALUES ('56', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:09');
INSERT INTO `customer` VALUES ('57', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:09');
INSERT INTO `customer` VALUES ('58', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:09');
INSERT INTO `customer` VALUES ('59', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:29');
INSERT INTO `customer` VALUES ('60', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:29');
INSERT INTO `customer` VALUES ('61', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:29');
INSERT INTO `customer` VALUES ('62', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:29');
INSERT INTO `customer` VALUES ('63', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:30');
INSERT INTO `customer` VALUES ('64', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:30');
INSERT INTO `customer` VALUES ('65', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:30');
INSERT INTO `customer` VALUES ('66', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:30');
INSERT INTO `customer` VALUES ('67', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:30');
INSERT INTO `customer` VALUES ('68', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:30');
INSERT INTO `customer` VALUES ('69', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:31');
INSERT INTO `customer` VALUES ('70', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:31');
INSERT INTO `customer` VALUES ('71', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:31');
INSERT INTO `customer` VALUES ('72', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:31');
INSERT INTO `customer` VALUES ('73', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:31');
INSERT INTO `customer` VALUES ('74', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:32');
INSERT INTO `customer` VALUES ('75', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:32');
INSERT INTO `customer` VALUES ('76', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:32');
INSERT INTO `customer` VALUES ('77', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:32');
INSERT INTO `customer` VALUES ('78', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:32');
INSERT INTO `customer` VALUES ('79', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:32');
INSERT INTO `customer` VALUES ('80', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:33');
INSERT INTO `customer` VALUES ('81', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:33');
INSERT INTO `customer` VALUES ('82', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:33');
INSERT INTO `customer` VALUES ('83', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:33');
INSERT INTO `customer` VALUES ('84', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:33');
INSERT INTO `customer` VALUES ('85', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:33');
INSERT INTO `customer` VALUES ('86', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:34');
INSERT INTO `customer` VALUES ('87', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:34');
INSERT INTO `customer` VALUES ('88', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:34');
INSERT INTO `customer` VALUES ('89', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:34');
INSERT INTO `customer` VALUES ('90', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:34');
INSERT INTO `customer` VALUES ('91', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:34');
INSERT INTO `customer` VALUES ('92', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:35');
INSERT INTO `customer` VALUES ('93', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:35');
INSERT INTO `customer` VALUES ('94', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:35');
INSERT INTO `customer` VALUES ('95', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:35');
INSERT INTO `customer` VALUES ('96', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:35');
INSERT INTO `customer` VALUES ('97', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:36');
INSERT INTO `customer` VALUES ('98', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:36');
INSERT INTO `customer` VALUES ('99', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:36');
INSERT INTO `customer` VALUES ('100', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:36');
INSERT INTO `customer` VALUES ('101', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:36');
INSERT INTO `customer` VALUES ('102', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:36');
INSERT INTO `customer` VALUES ('103', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:37');
INSERT INTO `customer` VALUES ('104', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:37');
INSERT INTO `customer` VALUES ('105', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:37');
INSERT INTO `customer` VALUES ('106', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:37');
INSERT INTO `customer` VALUES ('107', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:37');
INSERT INTO `customer` VALUES ('108', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:38');
INSERT INTO `customer` VALUES ('109', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:38');
INSERT INTO `customer` VALUES ('110', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:38');
INSERT INTO `customer` VALUES ('111', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:38');
INSERT INTO `customer` VALUES ('112', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:38');
INSERT INTO `customer` VALUES ('113', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:38');
INSERT INTO `customer` VALUES ('114', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:39');
INSERT INTO `customer` VALUES ('115', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:39');
INSERT INTO `customer` VALUES ('116', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:39');
INSERT INTO `customer` VALUES ('117', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:39');
INSERT INTO `customer` VALUES ('118', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:39');
INSERT INTO `customer` VALUES ('119', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:40');
INSERT INTO `customer` VALUES ('120', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:40');
INSERT INTO `customer` VALUES ('121', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:40');
INSERT INTO `customer` VALUES ('122', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:40');
INSERT INTO `customer` VALUES ('123', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:40');
INSERT INTO `customer` VALUES ('124', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:40');
INSERT INTO `customer` VALUES ('125', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:41');
INSERT INTO `customer` VALUES ('126', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:41');
INSERT INTO `customer` VALUES ('127', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:41');
INSERT INTO `customer` VALUES ('128', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:41');
INSERT INTO `customer` VALUES ('129', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:41');
INSERT INTO `customer` VALUES ('130', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:42');
INSERT INTO `customer` VALUES ('131', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:42');
INSERT INTO `customer` VALUES ('132', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:42');
INSERT INTO `customer` VALUES ('133', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:42');
INSERT INTO `customer` VALUES ('134', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:42');
INSERT INTO `customer` VALUES ('135', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:42');
INSERT INTO `customer` VALUES ('136', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:43');
INSERT INTO `customer` VALUES ('137', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:43');
INSERT INTO `customer` VALUES ('138', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:43');
INSERT INTO `customer` VALUES ('139', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:43');
INSERT INTO `customer` VALUES ('140', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:43');
INSERT INTO `customer` VALUES ('141', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:44');
INSERT INTO `customer` VALUES ('142', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:44');
INSERT INTO `customer` VALUES ('143', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:44');
INSERT INTO `customer` VALUES ('144', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:44');
INSERT INTO `customer` VALUES ('145', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:44');
INSERT INTO `customer` VALUES ('146', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:44');
INSERT INTO `customer` VALUES ('147', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:45');
INSERT INTO `customer` VALUES ('148', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:45');
INSERT INTO `customer` VALUES ('149', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:45');
INSERT INTO `customer` VALUES ('150', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:45');
INSERT INTO `customer` VALUES ('151', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:45');
INSERT INTO `customer` VALUES ('152', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:46');
INSERT INTO `customer` VALUES ('153', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:46');
INSERT INTO `customer` VALUES ('154', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:46');
INSERT INTO `customer` VALUES ('155', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:46');
INSERT INTO `customer` VALUES ('156', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:46');
INSERT INTO `customer` VALUES ('157', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:46');
INSERT INTO `customer` VALUES ('158', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:47');
INSERT INTO `customer` VALUES ('159', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:47');
INSERT INTO `customer` VALUES ('160', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:47');
INSERT INTO `customer` VALUES ('161', '马云', null, null, '6', '2', '22', '马化腾', '0108888887', '13888888888', '123456', '北京三里桥', '2016-04-08 16:32:47');

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `user_id` bigint(32) NOT NULL AUTO_INCREMENT COMMENT '用户id',
  `user_code` varchar(32) NOT NULL COMMENT '用户账号',
  `user_name` varchar(64) NOT NULL COMMENT '用户名称',
  `user_password` varchar(32) NOT NULL COMMENT '用户密码',
  `user_state` char(1) NOT NULL COMMENT '1:正常,0:暂停',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES ('5', 'm0003', '小军', '123', '1');
INSERT INTO `sys_user` VALUES ('6', 'm0001', '小红', '123', '1');
INSERT INTO `sys_user` VALUES ('7', 'm0001', '小明', '123', '1');
INSERT INTO `sys_user` VALUES ('8', 'm0001', '小红', '123', '1');

SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

三、工程搭建

使用的Bootstrap的前端框架,工程使用SpringMVC、Spring、Mybatis框架整合完成。
1、创建项目
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

2、需要的jar包:下载jar地址:https://download.csdn.net/download/qq_44757034/16522518
Spring(包括SpringMVC)
Mybatis
MyBatis-Spring整合包
数据库驱动
第三方连接池
Json依赖包Jackson

导入jar
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
3、整合思路
(一)Dao层
(1)创建config目录以及SqlMapConfig.xml
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

</configuration>

(2)applicationContext-dao.xml
a、数据库连接
b、SqlSessionFactory对象,需要spring和mybatis整合包下的
c、配置mapper文件扫描器
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
	<!-- 配置 读取properties文件 jdbc.properties -->
	<context:property-placeholder location="classpath:jdbc.properties" />
	<!-- 配置 数据源 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>
	<!-- 配置SqlSessionFactory -->
	<bean class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 设置MyBatis核心配置文件 -->
		<property name="configLocation" value="classpath:SqlMapConfig.xml" />
		<!-- 别名包扫描 -->
		<property name="typeAliasesPackage" value="com.itzheng.crm.pojo" ></property>
		<!-- 设置数据源 -->
		<property name="dataSource" ref="dataSource" />
	</bean>
	<!-- 配置Mapper扫描 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- 设置Mapper扫描包 -->
		<property name="basePackage" value="com.itzheng.crm.mapper" />
	</bean>
</beans>

(3)创建jdbc.properties
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/crm ?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

(4)创建log4j.properties
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

# Global logging configuration
log4j.rootLogger=debug, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

(5)创建包:com.itzheng.crm.pojo
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
(6)创建包:com.itzheng.crm.mapper
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

(二)Service层
(1)applicationContext-service.xml包扫描。扫描@service注解的类。
创建
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
	<!-- 配置@Service类的包扫描 -->
	<context:component-scan base-package="com.itzheng.crm.service"/>
</beans>

(2)applicationContext-trans.xml配置事务。
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
	<!-- 事务管理器 -->
	<bean id="transactionManager"	class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<!-- 数据源 -->
		<property name="dataSource" ref="dataSource" />
	</bean>
	<!-- 通知 -->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<!-- 传播行为 -->
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="insert*" propagation="REQUIRED" />
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="create*" propagation="REQUIRED" />
			<tx:method name="delete*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
			<tx:method name="select*" propagation="SUPPORTS" read-only="true" />
			<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
			<tx:method name="query*" propagation="SUPPORTS" read-only="true" />
		</tx:attributes>
	</tx:advice>
	<!-- 切面 -->
	<aop:config>
		<aop:advisor advice-ref="txAdvice"
			pointcut="execution(* com.itzheng.crm.service.*.*(..))" />
	</aop:config>
</beans>

(三)Controller层
包扫描器、扫描@Controller注解的类。
配置注解驱动
配置视图解析器
(1)创建包com.itzheng.crm.controller
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
(2)创建JSP目录
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

(3)创建springmvc.xml
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?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"
	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-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
	<!-- 配置Controller扫描 -->
	<context:component-scan base-package="com.itzheng.crm.controller" />

	<!-- 配置注解驱动 -->
	<mvc:annotation-driven />

	<!-- 配置视图解析器 -->
	<bean	class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- 前缀 -->
		<property name="prefix" value="/WEB-INF/jsp/" />
		<!-- 后缀 -->
		<property name="suffix" value=".jsp" />
	</bean>
</beans>

(四)Web.xml文件
配置Spring
配置前端控制器
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">
	<display-name>boot-crm</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>

	<!-- 配置spring -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring/applicationContext-*.xml</param-value>
	</context-param>

	<!-- 配置监听器加载spring -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- 配置过滤器,解决post的乱码问题 -->
	<filter>
		<filter-name>encoding</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>encoding</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- 配置SpringMVC -->
	<servlet>
		<servlet-name>boot-crm</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/springmvc.xml</param-value>
		</init-param>
		<!-- 配置springmvc什么时候启动,参数必须为整数 -->
		<!-- 如果为0或者大于0,则springMVC随着容器启动而启动 -->
		<!-- 如果小于0,则在第一次请求进来的时候启动 -->
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>boot-crm</servlet-name>
		<!-- 所有的请求都进入springMVC -->
		<url-pattern>*.action</url-pattern>
	</servlet-mapping>
</web-app>

四、静态资源加入

下载JSP页面代码直接导入到项目当中:JSP页面下载地址:https://download.csdn.net/download/qq_44757034/16528744
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
1、创建控制器:CustomerController
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/*
 * 客户信息请求处理
 */
@Controller
@RequestMapping("customer")
public class CustomerController {
	@RequestMapping("list")
	public String list() {
		return "customer";
	}
}

2、创建customer.jsp
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itzheng" uri="http://itzheng.cn/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<title>客户列表-BootCRM</title>

<!-- Bootstrap Core CSS -->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

<!-- MetisMenu CSS -->
<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet">

<!-- DataTables CSS -->
<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet">

<!-- Custom Fonts -->
<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet"
	type="text/css">
<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet"
	type="text/css">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

	<div id="wrapper">

		<!-- Navigation -->
		<nav class="navbar navbar-default navbar-static-top" role="navigation"
			style="margin-bottom: 0">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target=".navbar-collapse">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="index.html">BOOT客户管理系统 v2.0</a>
		</div>
		<!-- /.navbar-header -->

		<ul class="nav navbar-top-links navbar-right">
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-envelope fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-messages">
					<li><a href="#">
							<div>
								<strong>令狐冲</strong> <span class="pull-right text-muted">
									<em>昨天</em>
								</span>
							</div>
							<div>今天晚上向大哥找我吃饭,讨论一下去梅庄的事...</div>
					</a></li>
					<li class="divider"></li>
					<li><a class="text-center" href="#"> <strong>查看全部消息</strong>
							<i class="fa fa-angle-right"></i>
					</a></li>
				</ul> <!-- /.dropdown-messages --></li>
			<!-- /.dropdown -->
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-tasks fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-tasks">
					<li><a href="#">
							<div>
								<p>
									<strong>任务 1</strong> <span class="pull-right text-muted">完成40%</span>
								</p>
								<div class="progress progress-striped active">
									<div class="progress-bar progress-bar-success"
										role="progressbar" aria-valuenow="40" aria-valuemin="0"
										aria-valuemax="100" style="width: 40%">
										<span class="sr-only">完成40%</span>
									</div>
								</div>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<p>
									<strong>任务 2</strong> <span class="pull-right text-muted">完成20%</span>
								</p>
								<div class="progress progress-striped active">
									<div class="progress-bar progress-bar-info" role="progressbar"
										aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
										style="width: 20%">
										<span class="sr-only">完成20%</span>
									</div>
								</div>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a class="text-center" href="#"> <strong>查看所有任务</strong>
							<i class="fa fa-angle-right"></i>
					</a></li>
				</ul> <!-- /.dropdown-tasks --></li>
			<!-- /.dropdown -->
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-bell fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-alerts">
					<li><a href="#">
							<div>
								<i class="fa fa-comment fa-fw"></i> 新回复 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<i class="fa fa-envelope fa-fw"></i> 新消息 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<i class="fa fa-tasks fa-fw"></i> 新任务 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a href="#">
							<div>
								<i class="fa fa-upload fa-fw"></i> 服务器重启 <span
									class="pull-right text-muted small">4分钟之前</span>
							</div>
					</a></li>
					<li class="divider"></li>
					<li><a class="text-center" href="#"> <strong>查看所有提醒</strong>
							<i class="fa fa-angle-right"></i>
					</a></li>
				</ul> <!-- /.dropdown-alerts --></li>
			<!-- /.dropdown -->
			<li class="dropdown"><a class="dropdown-toggle"
				data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i>
					<i class="fa fa-caret-down"></i>
			</a>
				<ul class="dropdown-menu dropdown-user">
					<li><a href="#"><i class="fa fa-user fa-fw"></i> 用户设置</a></li>
					<li><a href="#"><i class="fa fa-gear fa-fw"></i> 系统设置</a></li>
					<li class="divider"></li>
					<li><a href="login.html"><i class="fa fa-sign-out fa-fw"></i>
							退出登录</a></li>
				</ul> <!-- /.dropdown-user --></li>
			<!-- /.dropdown -->
		</ul>
		<!-- /.navbar-top-links -->

		<div class="navbar-default sidebar" role="navigation">
			<div class="sidebar-nav navbar-collapse">
				<ul class="nav" id="side-menu">
					<li class="sidebar-search">
						<div class="input-group custom-search-form">
							<input type="text" class="form-control" placeholder="查询内容...">
							<span class="input-group-btn">
								<button class="btn btn-default" type="button">
									<i class="fa fa-search" style="padding: 3px 0 3px 0;"></i>
								</button>
							</span>
						</div> <!-- /input-group -->
					</li>
					<li><a href="customer.action" class="active"><i
							class="fa fa-edit fa-fw"></i> 客户管理</a></li>
					<li><a href="salevisit.action"><i
							class="fa fa-dashboard fa-fw"></i> 客户拜访</a></li>
				</ul>
			</div>
			<!-- /.sidebar-collapse -->
		</div>
		<!-- /.navbar-static-side --> </nav>

		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">客户管理</h1>
				</div>
				<!-- /.col-lg-12 -->
			</div>
			<!-- /.row -->
			<div class="panel panel-default">
				<div class="panel-body">
					<form class="form-inline" action="${pageContext.request.contextPath }/customer/list.action" method="get">
						<div class="form-group">
							<label for="customerName">客户名称</label> 
							<input type="text" class="form-control" id="customerName" value="${vo.custName }" name="custName">
						</div>
						<div class="form-group">
							<label for="customerFrom">客户来源</label> 
							<select	class="form-control" id="customerFrom" placeholder="客户来源" name="custSource">
								<option value="">--请选择--</option>
								<c:forEach items="${fromType}" var="item">
									<option value="${item.dict_id}"<c:if test="${item.dict_id == vo.custSource}"> selected</c:if>>${item.dict_item_name }</option>
								</c:forEach>
							</select>
						</div>
						<div class="form-group">
							<label for="custIndustry">所属行业</label> 
							<select	class="form-control" id="custIndustry"  name="custIndustry">
								<option value="">--请选择--</option>
								<c:forEach items="${industryType}" var="item">
									<option value="${item.dict_id}"<c:if test="${item.dict_id == vo.custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
								</c:forEach>
							</select>
						</div>
						<div class="form-group">
							<label for="custLevel">客户级别</label>
							<select	class="form-control" id="custLevel" name="custLevel">
								<option value="">--请选择--</option>
								<c:forEach items="${levelType}" var="item">
									<option value="${item.dict_id}"<c:if test="${item.dict_id == vo.custLevel}"> selected</c:if>>${item.dict_item_name }</option>
								</c:forEach>
							</select>
						</div>
						<button type="submit" class="btn btn-primary">查询</button>
					</form>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">客户信息列表</div>
						<!-- /.panel-heading -->
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>ID</th>
									<th>客户名称</th>
									<th>客户来源</th>
									<th>客户所属行业</th>
									<th>客户级别</th>
									<th>固定电话</th>
									<th>手机</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${page.rows}" var="row">
									<tr>
										<td>${row.cust_id}</td>
										<td>${row.cust_name}</td>
										<td>${row.cust_source}</td>
										<td>${row.cust_industry}</td>
										<td>${row.cust_level}</td>
										<td>${row.cust_phone}</td>
										<td>${row.cust_mobile}</td>
										<td>
											<a href="#" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#customerEditDialog" onclick="editCustomer(${row.cust_id})">修改</a>
											<a href="#" class="btn btn-danger btn-xs" onclick="deleteCustomer(${row.cust_id})">删除</a>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
						<div class="col-md-12 text-right">
							<itzheng:page url="${pageContext.request.contextPath }/customer/list.action" />
						</div>
						<!-- /.panel-body -->
					</div>
					<!-- /.panel -->
				</div>
				<!-- /.col-lg-12 -->
			</div>
		</div>
		<!-- /#page-wrapper -->

	</div>
	<!-- 客户编辑对话框 -->
	<div class="modal fade" id="customerEditDialog" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">修改客户信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="edit_customer_form">
						<input type="hidden" id="edit_cust_id" name="cust_id"/>
						<div class="form-group">
							<label for="edit_customerName" class="col-sm-2 control-label">客户名称</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_customerName" placeholder="客户名称" name="cust_name">
							</div>
						</div>
						<div class="form-group">
							<label for="edit_customerFrom" style="float:left;padding:7px 15px 0 27px;">客户来源</label> 
							<div class="col-sm-10">
								<select	class="form-control" id="edit_customerFrom" placeholder="客户来源" name="cust_source">
									<option value="">--请选择--</option>
									<c:forEach items="${fromType}" var="item">
										<option value="${item.dict_id}"<c:if test="${item.dict_id == custSource}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="edit_custIndustry" style="float:left;padding:7px 15px 0 27px;">所属行业</label>
							<div class="col-sm-10"> 
								<select	class="form-control" id="edit_custIndustry"  name="cust_industry">
									<option value="">--请选择--</option>
									<c:forEach items="${industryType}" var="item">
										<option value="${item.dict_id}"<c:if test="${item.dict_id == custIndustry}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="edit_custLevel" style="float:left;padding:7px 15px 0 27px;">客户级别</label>
							<div class="col-sm-10">
								<select	class="form-control" id="edit_custLevel" name="cust_level">
									<option value="">--请选择--</option>
									<c:forEach items="${levelType}" var="item">
										<option value="${item.dict_id}"<c:if test="${item.dict_id == custLevel}"> selected</c:if>>${item.dict_item_name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="edit_linkMan" class="col-sm-2 control-label">联系人</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_linkMan" placeholder="联系人" name="cust_linkman">
							</div>
						</div>
						<div class="form-group">
							<label for="edit_phone" class="col-sm-2 control-label">固定电话</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_phone" placeholder="固定电话" name="cust_phone">
							</div>
						</div>
						<div class="form-group">
							<label for="edit_mobile" class="col-sm-2 control-label">移动电话</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_mobile" placeholder="移动电话" name="cust_mobile">
							</div>
						</div>
						<div class="form-group">
							<label for="edit_zipcode" class="col-sm-2 control-label">邮政编码</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_zipcode" placeholder="邮政编码" name="cust_zipcode">
							</div>
						</div>
						<div class="form-group">
							<label for="edit_address" class="col-sm-2 control-label">联系地址</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="edit_address" placeholder="联系地址" name="cust_address">
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" onclick="updateCustomer()">保存修改</button>
				</div>
			</div>
		</div>
	</div>
	<!-- /#wrapper -->

	<!-- jQuery -->
	<script src="<%=basePath%>js/jquery.min.js"></script>

	<!-- Bootstrap Core JavaScript -->
	<script src="<%=basePath%>js/bootstrap.min.js"></script>

	<!-- Metis Menu Plugin JavaScript -->
	<script src="<%=basePath%>js/metisMenu.min.js"></script>

	<!-- DataTables JavaScript -->
	<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
	<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>

	<!-- Custom Theme JavaScript -->
	<script src="<%=basePath%>js/sb-admin-2.js"></script>
	
	<script type="text/javascript">
		function editCustomer(id) {
			$.ajax({
				type:"get",
				url:"<%=basePath%>customer/edit.action",
				data:{"id":id},
				success:function(data) {
					$("#edit_cust_id").val(data.cust_id);
					$("#edit_customerName").val(data.cust_name);
					$("#edit_customerFrom").val(data.cust_source)
					$("#edit_custIndustry").val(data.cust_industry)
					$("#edit_custLevel").val(data.cust_level)
					$("#edit_linkMan").val(data.cust_linkman);
					$("#edit_phone").val(data.cust_phone);
					$("#edit_mobile").val(data.cust_mobile);
					$("#edit_zipcode").val(data.cust_zipcode);
					$("#edit_address").val(data.cust_address);
					
				}
			});
		}
		function updateCustomer() {
			alert($("#edit_customer_form").serialize());
			$.post("<%=basePath%>customer/update.action",$("#edit_customer_form").serialize(),function(data){
				if(data == "0"){
					alert("客户信息更新成功!");
				}else{
					alert("客户信息更新失败!");
				}
				window.location.reload();
			});
		}
		
		function deleteCustomer(id) {
			if(confirm('确实要删除该客户吗?')) {
				$.post("<%=basePath%>customer/delete.action",{"id":id},function(data){
					if(data == "0"){
						alert("客户信息删除成功!");
					}else{
						alert("客户信息删除失败!");
					}
					window.location.reload();
				});
			}
		}
	</script>
</body>
</html>

3、引入自定义标签
(1)编写自定义标签的文件tld
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
	<tlib-version>2.0</tlib-version>
	<jsp-version>1.2</jsp-version>
	<short-name>common</short-name>
	<uri>http://itzheng.cn/common/</uri>
	<display-name>Common Tag</display-name>
	<description>Common Tag library</description>

	<tag>
		<name>page</name>
		<tag-class>com.itzheng.crm.utils.NavigationTag</tag-class>
		<body-content>JSP</body-content>
		<description>create navigation for paging</description>
		<attribute>
			<name>bean</name>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>number</name>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>url</name>
			<required>true</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
	</tag>
</taglib>

(2)创建自定义标签的类:NavigationTag和Page类
a、Page
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.utils;
import java.util.List;
public class Page<T> {
	private int total;
	private int page;
	private int size;
	private List<T> rows;
	public Page() {
		super();
	}
	/**
	 * 
	 * @param total 查询数据总条数
	 * @param page  当前页码数
	 * @param size  每页显示数据条数
	 * @param rows  查询结果集
	 */
	public Page(int total, int page, int size, List<T> rows) {
		super();
		this.total = total;
		this.page = page;
		this.size = size;
		this.rows = rows;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getSize() {
		return size;
	}
	public void setSize(int size) {
		this.size = size;
	}
	public List<T> getRows() {
		return rows;
	}
	public void setRows(List<T> rows) {
		this.rows = rows;
	}
}

b、NavigationTag
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * 显示格式 上一页 1 2 3 4 5 下一页
 */
public class NavigationTag extends TagSupport {
	static final long serialVersionUID = 2372405317744358833L;

	/**
	 * request 中用于保存Page<E> 对象的变量名,默认为“page”
	 */
	private String bean = "page";

	/**
	 * 分页跳转的url地址,此属性必须
	 */
	private String url = null;

	/**
	 * 显示页码数量
	 */
	private int number = 5;

	@Override
	public int doStartTag() throws JspException {
		JspWriter writer = pageContext.getOut();
		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
		Page page = (Page) request.getAttribute(bean);
		if (page == null)
			return SKIP_BODY;
		url = resolveUrl(url, pageContext);
		try {
			// 计算总页数
			int pageCount = page.getTotal() / page.getSize();
			if (page.getTotal() % page.getSize() > 0) {
				pageCount++;
			}
			writer.print("<nav><ul class=\"pagination\">");
			// 显示“上一页”按钮
			if (page.getPage() > 1) {
				String preUrl = append(url, "page", page.getPage() - 1);
				preUrl = append(preUrl, "rows", page.getSize());
				writer.print("<li><a href=\"" + preUrl + "\">上一页</a></li>");
			} else {
				writer.print("<li class=\"disabled\"><a href=\"#\">上一页</a></li>");
			}
			// 显示当前页码的前2页码和后两页码
			// 若1 则 1 2 3 4 5, 若2 则 1 2 3 4 5, 若3 则1 2 3 4 5,
			// 若4 则 2 3 4 5 6 ,若10 则 8 9 10 11 12
			int indexPage = (page.getPage() - 2 > 0) ? page.getPage() - 2 : 1;
			for (int i = 1; i <= number && indexPage <= pageCount; indexPage++, i++) {
				if (indexPage == page.getPage()) {
					writer.print("<li class=\"active\"><a href=\"#\">" + indexPage
							+ "<span class=\"sr-only\">(current)</span></a></li>");
					continue;
				}
				String pageUrl = append(url, "page", indexPage);
				pageUrl = append(pageUrl, "rows", page.getSize());
				writer.print("<li><a href=\"" + pageUrl + "\">" + indexPage + "</a></li>");
			}
			// 显示“下一页”按钮
			if (page.getPage() < pageCount) {
				String nextUrl = append(url, "page", page.getPage() + 1);
				nextUrl = append(nextUrl, "rows", page.getSize());
				writer.print("<li><a href=\"" + nextUrl + "\">下一页</a></li>");
			} else {
				writer.print("<li class=\"disabled\"><a href=\"#\">下一页</a></li>");
			}
			writer.print("</nav>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return SKIP_BODY;
	}

	private String append(String url, String key, int value) {

		return append(url, key, String.valueOf(value));
	}

	/**
	 * 为url 参加参数对儿
	 * 
	 * @param url
	 * @param key
	 * @param value
	 * @return
	 */
	private String append(String url, String key, String value) {
		if (url == null || url.trim().length() == 0) {
			return "";
		}

		if (url.indexOf("?") == -1) {
			url = url + "?" + key + "=" + value;
		} else {
			if (url.endsWith("?")) {
				url = url + key + "=" + value;
			} else {
				url = url + "&amp;" + key + "=" + value;
			}
		}

		return url;
	}

	/**
	 * 为url 添加翻页请求参数
	 * 
	 * @param url
	 * @param pageContext
	 * @return
	 * @throws javax.servlet.jsp.JspException
	 */
	private String resolveUrl(String url, javax.servlet.jsp.PageContext pageContext) throws JspException {
		// UrlSupport.resolveUrl(url, context, pageContext)
		Map params = pageContext.getRequest().getParameterMap();
		for (Object key : params.keySet()) {
			if ("page".equals(key) || "rows".equals(key))
				continue;
			Object value = params.get(key);
			if (value == null)
				continue;
			try {
				if (value.getClass().isArray()) {
					// 解决GET乱码问题
					// value = new String(((String[])
					// value)[0].getBytes("ISO-8859-1"), "UTF-8");

					value = ((String[]) value)[0];
					url = append(url, key.toString(), value.toString());
				} else if (value instanceof String) {
					// 解决GET乱码问题
					// value = new String(((String)
					// value).getBytes("ISO-8859-1"), "UTF-8");
					value = (String) value;
					url = append(url, key.toString(), value.toString());
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return url;
	}

	/**
	 * @return the bean
	 */
	public String getBean() {
		return bean;
	}

	/**
	 * @param bean the bean to set
	 */
	public void setBean(String bean) {
		this.bean = bean;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	public void setNumber(int number) {
		this.number = number;
	}

}

3、运行项目,并测试
http://localhost:8080/boot-crm/customer/list.action
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

五、自定义标签

1、创建自定义标签类MyTag类
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
这个类要继承TagSupport

package com.itzheng.crm.utils;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/*
 * 自定义标签的使用
 */
public class MyTag extends TagSupport {
	
	
	@Override
	public int doStartTag() throws JspException {
		JspWriter out = super.pageContext.getOut();
		try {
			
			out.print("<span>这个是自定义标签输出的内容</span>");
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doStartTag();
	}
}

2、创建tld文件
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
	<tlib-version>2.0</tlib-version>
	<jsp-version>1.2</jsp-version>
	<short-name>myTag</short-name>
	<uri>http://itzheng/myTag/</uri>
	<tag>
		<name>out</name>
		<tag-class>com.itzheng.crm.utils.MyTag</tag-class>
		<body-content>JSP</body-content>
	</tag>
</taglib>

3、创建myTag.jsp页面,并引用创建好的标签
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="myTag" uri="http://itzheng/myTag/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>自定义标签的使用</title>
</head>
<body>
</body>
<myTag:out></myTag:out>
</html>

4、修改CustomerController类创建myTage方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

@RequestMapping("myTag")
	public String myTag() {
		System.out.println("-------------");
		return "myTag";
	}

5、运行并测试
http://localhost:8080/boot-crm/customer/myTag.action
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
6、输出其他内容使其在页面上显示,修改MyTag
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
再次运行并访问
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

六、项目实现:

1、查询条件加载

(1)创建接口
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.mapper;

/*
 * 字典数据表持久化接口
 */
public interface BaseDictMapper {

}

(2)创建BaseDict类
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.pojo;
/*
 * 字典数据模型
 */
public class BaseDict {
	private String dict_id;
	private String dict_type_code;
	private String dict_type_name;
	private String dict_item_name;
	private String dict_item_code;
	private String dict_sort;
	private String dict_enable;
	private String dict_memo;
	public String getDict_id() {
		return dict_id;
	}
	public void setDict_id(String dict_id) {
		this.dict_id = dict_id;
	}
	public String getDict_type_code() {
		return dict_type_code;
	}
	public void setDict_type_code(String dict_type_code) {
		this.dict_type_code = dict_type_code;
	}
	public String getDict_type_name() {
		return dict_type_name;
	}
	public void setDict_type_name(String dict_type_name) {
		this.dict_type_name = dict_type_name;
	}
	public String getDict_item_name() {
		return dict_item_name;
	}
	public void setDict_item_name(String dict_item_name) {
		this.dict_item_name = dict_item_name;
	}
	public String getDict_item_code() {
		return dict_item_code;
	}
	public void setDict_item_code(String dict_item_code) {
		this.dict_item_code = dict_item_code;
	}
	public String getDict_sort() {
		return dict_sort;
	}
	public void setDict_sort(String dict_sort) {
		this.dict_sort = dict_sort;
	}
	public String getDict_enable() {
		return dict_enable;
	}
	public void setDict_enable(String dict_enable) {
		this.dict_enable = dict_enable;
	}
	public String getDict_memo() {
		return dict_memo;
	}
	public void setDict_memo(String dict_memo) {
		this.dict_memo = dict_memo;
	}
	@Override
	public String toString() {
		return "BaseDict [dict_id=" + dict_id + ", dict_type_code=" + dict_type_code + ", dict_type_name="
				+ dict_type_name + ", dict_item_name=" + dict_item_name + ", dict_item_code=" + dict_item_code
				+ ", dict_sort=" + dict_sort + ", dict_enable=" + dict_enable + ", dict_memo=" + dict_memo + "]";
	}
}

(3)完善上述所创建的接口
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.mapper;
import java.util.List;
import com.itzheng.crm.pojo.BaseDict;
/*
 * 字典数据表持久化接口
 */
public interface BaseDictMapper {
	/*
	 * 根据字典编码查询字典列表
	 */
	List<BaseDict> getBaseBictByCode(String code);
}

(4)创建对应的映射文件:BaseDictMapper.xml
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?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.itzheng.crm.mapper.BaseDictMapper">
	<select id="getBaseDictByCode" parameterType="string" resultType="basedict">
		SELECT
		  `dict_id`,
		  `dict_type_code`,
		  `dict_type_name`,
		  `dict_item_name`,
		  `dict_item_code`,
		  `dict_sort`,
		  `dict_enable`,
		  `dict_memo`
		FROM `base_dict`
		WHERE dict_type_code = #{code}
	</select>
</mapper>

(4)创建BaseDictService
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.service;
import java.util.List;
import com.itzheng.crm.pojo.BaseDict;
/*
 * 字典数据表业务接口
 */
public interface BaseDictService {
	/*
	 * 根据字典编码查询字典列表
	 */
	List<BaseDict> getBaseDictByCode(String code);
}

(5)创建实现类BaseDictServiceImpl实现BaseDictService接口
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itzheng.crm.mapper.BaseDictMapper;
import com.itzheng.crm.pojo.BaseDict;
import com.itzheng.crm.service.BaseDictService;

@Service
public class BaseDictServiceImpl implements BaseDictService {
	
	@Autowired
	private BaseDictMapper baseDictMapper;

	@Override
	public List<BaseDict> getBaseDictByCode(String code) {
		return baseDictMapper.getBaseDictByCode(code);
	}

}

(6)控制层调用
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.itzheng.crm.pojo.BaseDict;
import com.itzheng.crm.service.BaseDictService;
/*
 * 客户信息请求处理
 */
@Controller
@RequestMapping("customer")
public class CustomerController {
	@Autowired
	private BaseDictService dictService;
	@RequestMapping("list")
	public String list(Model model) {
		//查询来源
		List<BaseDict> fromType = dictService.getBaseDictByCode("002");
		//查询行业
		List<BaseDict> industryType = dictService.getBaseDictByCode("001");	
		List<BaseDict> levelType = dictService.getBaseDictByCode("006"); 	
		//设置数据模型的返回
		model.addAttribute("fromType",fromType);	
		model.addAttribute("industryType",industryType);	
		model.addAttribute("levelType",levelType);
		return "customer";
	}
	@RequestMapping("myTag")
	public String myTag() {
		return "myTag";
	}
}

(7)运行并测试项目
http://localhost:8080/boot-crm/customer/list.action
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
(8)创建对应的数据加载文件:crm.properties
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

customer_from_type=002
customer_industry_type=001
customer_level_type=006

(9)加载上面的配置文件
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<!-- 属性文件的加载 -->
	<context:property-placeholder  location="classpath:crm.properties"  />

(10)CustomerController类当中绑定对应数据文件的值
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

/*
 * 客户信息请求处理
 */
@Controller
@RequestMapping("customer")
public class CustomerController {
	@Autowired
	private BaseDictService dictService;
	@Value("${customer_from_type}")
	private String  customer_from_type;
	@Value("${customer_industry_type}")
	private String  customer_industry_type;
	@Value("${customer_level_type}")
	private String  customer_level_type; 
	@RequestMapping("list")
	public String list(Model model) {
		//查询来源
		List<BaseDict> fromType = dictService.getBaseDictByCode(customer_from_type);
		//查询行业
		List<BaseDict> industryType = dictService.getBaseDictByCode(customer_industry_type);
		//查询级别的
		List<BaseDict> levelType = dictService.getBaseDictByCode(customer_level_type); 
		//设置数据模型的返回
		model.addAttribute("fromType",fromType);
		model.addAttribute("industryType",industryType);

(11)运行并测试http://localhost:8080/boot-crm/customer/list.action
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

2、条件查询实现

(1)创建POJO,Customer:客户信息数据模型
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.pojo;
import java.util.Date;
public class Customer {
	private Long cust_id;
	private String cust_name;
	private Long cust_user_id;
	private Long cust_create_id;
	private String cust_source;
	private String cust_industry;
	private String cust_level;
	private String cust_linkman;
	private String cust_phone;
	private String cust_mobile;
	private String cust_zipcode;
	private String cust_address;
	private Date cust_createtime;

	public Long getCust_id() {
		return cust_id;
	}

	public void setCust_id(Long cust_id) {
		this.cust_id = cust_id;
	}

	public String getCust_name() {
		return cust_name;
	}

	public void setCust_name(String cust_name) {
		this.cust_name = cust_name;
	}

	public Long getCust_user_id() {
		return cust_user_id;
	}

	public void setCust_user_id(Long cust_user_id) {
		this.cust_user_id = cust_user_id;
	}

	public Long getCust_create_id() {
		return cust_create_id;
	}

	public void setCust_create_id(Long cust_create_id) {
		this.cust_create_id = cust_create_id;
	}

	public String getCust_source() {
		return cust_source;
	}

	public void setCust_source(String cust_source) {
		this.cust_source = cust_source;
	}

	public String getCust_industry() {
		return cust_industry;
	}

	public void setCust_industry(String cust_industry) {
		this.cust_industry = cust_industry;
	}

	public String getCust_level() {
		return cust_level;
	}

	public void setCust_level(String cust_level) {
		this.cust_level = cust_level;
	}

	public String getCust_linkman() {
		return cust_linkman;
	}

	public void setCust_linkman(String cust_linkman) {
		this.cust_linkman = cust_linkman;
	}

	public String getCust_phone() {
		return cust_phone;
	}

	public void setCust_phone(String cust_phone) {
		this.cust_phone = cust_phone;
	}

	public String getCust_mobile() {
		return cust_mobile;
	}

	public void setCust_mobile(String cust_mobile) {
		this.cust_mobile = cust_mobile;
	}

	public String getCust_zipcode() {
		return cust_zipcode;
	}

	public void setCust_zipcode(String cust_zipcode) {
		this.cust_zipcode = cust_zipcode;
	}

	public String getCust_address() {
		return cust_address;
	}

	public void setCust_address(String cust_address) {
		this.cust_address = cust_address;
	}

	public Date getCust_createtime() {
		return cust_createtime;
	}

	public void setCust_createtime(Date cust_createtime) {
		this.cust_createtime = cust_createtime;
	}

	@Override
	public String toString() {
		return "Customer [cust_id=" + cust_id + ", cust_name=" + cust_name + ", cust_user_id=" + cust_user_id
				+ ", cust_create_id=" + cust_create_id + ", cust_source=" + cust_source + ", cust_industry="
				+ cust_industry + ", cust_level=" + cust_level + ", cust_linkman=" + cust_linkman + ", cust_phone="
				+ cust_phone + ", cust_mobile=" + cust_mobile + ", cust_zipcode=" + cust_zipcode + ", cust_address="
				+ cust_address + ", cust_createtime=" + cust_createtime + "]";
	}

}

(2)创建POJO,QueryVo:与页面上客户信息一致的内容
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.pojo;
public class QueryVo {

	private String custName;
	private String custSource;
	private String custIndustry;
	private String custLevel;
	
	// 当前页码数
	private Integer page = 1;
	// 数据库从那一条数据开始查
	private Integer start;
	// 每页显示数据条数
	private Integer rows = 10;
	public String getCustName() {
		return custName;
	}
	public void setCustName(String custName) {
		this.custName = custName;
	}
	public String getCustSource() {
		return custSource;
	}
	public void setCustSource(String custSource) {
		this.custSource = custSource;
	}
	public String getCustIndustry() {
		return custIndustry;
	}
	public void setCustIndustry(String custIndustry) {
		this.custIndustry = custIndustry;
	}
	public String getCustLevel() {
		return custLevel;
	}
	public void setCustLevel(String custLevel) {
		this.custLevel = custLevel;
	}
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	public Integer getStart() {
		return start;
	}
	public void setStart(Integer start) {
		this.start = start;
	}
	public Integer getRows() {
		return rows;
	}
	public void setRows(Integer rows) {
		this.rows = rows;
	}
	@Override
	public String toString() {
		return "QueryVo [custName=" + custName + ", custSource=" + custSource + ", custIndustry=" + custIndustry
				+ ", custLevel=" + custLevel + ", page=" + page + ", start=" + start + ", rows=" + rows + "]";
	}
}

(3)修改CustomerController的list方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
(4)创建CustomerMapper客户信息持久化接口
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.mapper;
import java.util.List;
import com.itzheng.crm.pojo.Customer;
import com.itzheng.crm.pojo.QueryVo;
/*
 * 客户信息持久化接口
 * 
 */
public interface CustomerMapper {
	/*
	 * 根据查询条件,分页查询用户列表
	 */
	List<Customer> getCustomerByQueryVo(QueryVo vo);
}

(5)创建CustomerMapper客户信息映射文件
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?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.itzheng.crm.mapper.CustomerMapper">
	<select id="getCustomerByQueryVo" parameterType="queryvo" resultType="customer" >
			SELECT
				c.`cust_id`,
				c.`cust_name`,
				c.`cust_user_id`,
				c.`cust_create_id`,
				s.`dict_item_name` `cust_source`,
				i.`dict_item_name` `cust_industry`,
				l.`dict_item_name` `cust_level`,
				c.`cust_linkman`,
				c.`cust_phone`,
				c.`cust_mobile`,
				c.`cust_zipcode`,
				c.`cust_address`,
				c.`cust_createtime`
			FROM `customer` c
				LEFT JOIN base_dict s ON c.`cust_source`= s.`dict_id`
				LEFT JOIN base_dict i ON c.`cust_industry` = i.`dict_id`
				LEFT JOIN base_dict l ON c.`cust_level` = l.`dict_id`
				<where>
					<if test="cust_name != null and cust_name != ''">
						and c.`cust_name` LIKE '%${ cust_name }%'
					</if>
					<if test="cust_industry != null and cust_industry != ''" >
						AND c.`cust_industry` = #{cust_industry}
					</if>
					<if test="cust_level != null and cust_level != ''" >
						AND c.`cust_level` = #{cust_level}
					</if>
				</where>
				LIMIT #{start}, #{rows};
	</select>
</mapper>

(6)创建CustomerMapper当中根据查询条件查询总记录数
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	/*
	 * 根据查询条件查询总记录数
	 */
	Integer getCountByQueryVo(QueryVo vo);

(7)创建CustomerMapper当中根据查询条件查询总记录数对应的映射文件
抽取查询条件
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)


	<select id="getCountByQueryVo" parameterType="int"  resultType="queryvo" >
			SELECT count(1)
			FROM `customer` c
				LEFT JOIN base_dict s ON c.`cust_source`= s.`dict_id`
				LEFT JOIN base_dict i ON c.`cust_industry` = i.`dict_id`
				LEFT JOIN base_dict l ON c.`cust_level` = l.`dict_id`
			<include refid="customer_where"/>
	</select>
	

抽取
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

<?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.itzheng.crm.mapper.CustomerMapper">

	<sql id="customer_where">
		<where>
			<if test="custName != null and custName != ''">
				and c.`cust_name` LIKE '%${custName}%'
			</if>
			<if test="custSource != null and custSource != ''">
				AND c.`cust_source` = #{custSource}
			</if>
			<if test="custIndustry != null and custIndustry != ''">
				AND c.`cust_industry` = #{custIndustry}
			</if>
			<if test="custLevel != null and custLevel != ''">
				AND c.`cust_level` = #{custLevel}
			</if>
		</where>
	</sql>

	<select id="getCustomerByQueryVo" parameterType="queryvo" resultType="customer" >
			SELECT
				c.`cust_id`,
				c.`cust_name`,
				c.`cust_user_id`,
				c.`cust_create_id`,
				s.`dict_item_name` `cust_source`,
				i.`dict_item_name` `cust_industry`,
				l.`dict_item_name` `cust_level`,
				c.`cust_linkman`,
				c.`cust_phone`,
				c.`cust_mobile`,
				c.`cust_zipcode`,
				c.`cust_address`,
				c.`cust_createtime`
			FROM `customer` c
				LEFT JOIN base_dict s ON c.`cust_source`= s.`dict_id`
				LEFT JOIN base_dict i ON c.`cust_industry` = i.`dict_id`
				LEFT JOIN base_dict l ON c.`cust_level` = l.`dict_id`
				<include refid="customer_where"/>
				LIMIT #{start}, #{rows};
	</select>
	
	<select id="getCountByQueryVo" parameterType="int"  resultType="queryvo" >
			SELECT count(1)
			FROM `customer` c
				LEFT JOIN base_dict s ON c.`cust_source`= s.`dict_id`
				LEFT JOIN base_dict i ON c.`cust_industry` = i.`dict_id`
				LEFT JOIN base_dict l ON c.`cust_level` = l.`dict_id`
			<include refid="customer_where"/>
	</select>
	
	
</mapper>

(8)创建CustomerService接口
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.service;
import java.util.List;
import com.itzheng.crm.pojo.Customer;
import com.itzheng.crm.pojo.QueryVo;
import com.itzheng.crm.utils.Page;
/*
 * 客户信息业务逻辑接口
 * 
 */
public interface CustomerService {
	/*
	 * 根据查询条件,分页查询用户列表
	 */
	Page<Customer> getCustomerByQueryVo(QueryVo vo);
}

(9)创建CustomerService接口的实现类
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.itzheng.crm.mapper.CustomerMapper;
import com.itzheng.crm.pojo.Customer;
import com.itzheng.crm.pojo.QueryVo;
import com.itzheng.crm.service.CustomerService;
import com.itzheng.crm.utils.Page;
@Service
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	private CustomerMapper customerMapper;
	@Override
	public Page<Customer> getCustomerByQueryVo(QueryVo vo) {
		// 计算分页查询那条记录开始
		vo.setStart((vo.getPage() - 1) * vo.getRows());
		// 查询总记录数
		Integer total = customerMapper.getCountByQueryVo(vo);
		// 查询每一页的数据列表
		List<Customer> list = customerMapper.getCustomerByQueryVo(vo);
		// 包装分页数据
		Page<Customer> page = new Page<Customer>(total, vo.getPage(), vo.getRows(), list);
		return page;
	}
}

(10)修改CustomerController当中注入CustomerService
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

package com.itzheng.crm.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.itzheng.crm.pojo.BaseDict;
import com.itzheng.crm.pojo.Customer;
import com.itzheng.crm.pojo.QueryVo;
import com.itzheng.crm.service.BaseDictService;
import com.itzheng.crm.service.CustomerService;
import com.itzheng.crm.utils.Page;
/*
 * 客户信息请求处理
 */
@Controller
@RequestMapping("customer")
public class CustomerController {
	@Autowired
	private BaseDictService dictService;
	@Autowired
	private CustomerService customerService;
	@Value("${customer_from_type}")
	private String customer_from_type;
	@Value("${customer_industry_type}")
	private String customer_industry_type;
	@Value("${customer_level_type}")
	private String customer_level_type;
	@RequestMapping("list")
	public String list(Model model, QueryVo vo) {
		// 查询来源
		List<BaseDict> fromType = dictService.getBaseDictByCode(customer_from_type);
		// 查询行业
		List<BaseDict> industryType = dictService.getBaseDictByCode(customer_industry_type);
		// 查询级别的
		List<BaseDict> levelType = dictService.getBaseDictByCode(customer_level_type);
		// 设置数据模型的返回
		model.addAttribute("fromType", fromType);
		model.addAttribute("industryType", industryType);
		model.addAttribute("levelType", levelType);
		// 根据查询条件分页查询用户列表
		Page<Customer> page = customerService.getCustomerByQueryVo(vo);
		//设置分页数据返回
		model.addAttribute("page", page);
		return "customer";
	}
	@RequestMapping("myTag")
	public String myTag() {
		return "myTag";
	}
}

(11)运行并测试
http://localhost:8080/boot-crm/customer/list.action
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

3、修改用户信息

(1)先查询出对应id的用户信息
a、创建持久层修改CustomerMapper当中创建getCustomerById方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

/*
	 * 根据id查询用户信息
	 */
	Customer getCustomerById(Integer id);

b、完善对应的映射文件,和其中的SQL语句
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)


	<select id="getCustomerById"  parameterType="int" resultType="customer" >
		SELECT 	
			`cust_id`, 
			`cust_name`, 
			`cust_user_id`, 
			`cust_create_id`, 
			`cust_source`, 
			`cust_industry`, 
			`cust_level`, 
			`cust_linkman`, 
			`cust_phone`, 
			`cust_mobile`, 
			`cust_zipcode`, 
			`cust_address`, 
			`cust_createtime`
			 
		FROM  `customer` 
		WHERE `cust_id` = #{id}
	</select>
	

c、完善service层
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

/*
	 * 根据id查询用户信息
	 */
	Customer getCustomerById(Integer id);

d、完善service层的实现类
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	@Override
	public Customer getCustomerById(Integer id) {
		return customerMapper.getCustomerById(id);
	}

e、完善控制层的CustomerController类当中edit方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

@RequestMapping("edit")
	@ResponseBody
	public Customer edit(Integer id) {
		Customer customer = customerService.getCustomerById(id);
		return customer;
	}

f、运行测试http://localhost:8080/boot-crm/customer/list.action
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
(2)修改上面页面当中的内容后保存内容
a、CustomerMapper接口当中创建更新用户信息的方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
b、CustomerMapper接口当中创建updateCustomer方法

	/*
	 * 更新用户信息
	 */
	void updateCustomer(Customer customer);

c、CustomerMapper.xml映射文件当中创建对应的更新语句
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	<update id="updateCustomer"  parameterType="customer" >
		UPDATE `customer` 
			<set>
				<if test="cust_name != null" >
					`cust_name` = #{cust_name},
				</if>
				<if test="cust_source != null and cust_source != '' " >
					`cust_source` = #{cust_source},
				</if>
				<if test="cust_industry != null and cust_industry != '' " >
					`cust_industry` = #{cust_industry},
				</if>
				<if test="cust_level != null and cust_level != '' " >
					`cust_level` = #{cust_level},
				</if>
				<if test="cust_linkman != null and cust_linkman != '' " >
					`cust_linkman` = #{cust_linkman},
				</if>
				<if test="cust_phone != null and cust_phone != '' " >
					`cust_phone` = #{cust_phone},
				</if>
				<if test="cust_mobile != null and cust_mobile != '' " >
					`cust_mobile` = #{cust_mobile},
				</if>
				<if test="cust_zipcode != null and cust_zipcode != '' " >
					`cust_zipcode` = #{cust_zipcode},
				</if>
				<if test="cust_address != null and cust_address != '' " >
					`cust_address` = #{cust_address},
				</if>
			</set>
			WHERE
				`cust_id` = #{cust_id};
	</update>

d、CustomerService接口当中创建更新用户信息的方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	/*
	 * 更新用户信息
	 */
	void updateCustomer(Customer customer);

e、对应的实现类当中
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)


	@Override
	public void updateCustomer(Customer customer) {
		
		customerMapper.updateCustomer(customer);
		
	}

f、控制层CustomerController当中创建update方法调用业务层
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

@RequestMapping("update")
	@ResponseBody
	public String update(Customer customer) {
		String msg = "1";
		try {
			customerService.updateCustomer(customer);
			msg = "0";
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}

g、修改页面返回对应的响应信息
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

function updateCustomer() {
			alert($("#edit_customer_form").serialize());
			$.post("<%=basePath%>customer/update.action",$("#edit_customer_form").serialize(),function(data){
				if(data == "0"){
					alert("客户信息更新成功!");
				}else{
					alert("客户信息更新失败!");
				}
				window.location.reload();	
			});
}

h、运行并测试
http://localhost:8080/boot-crm/customer/list.action
点击修改
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

4、删除用户信息

(1)CustomerMapper接口当中创建删除用户的方法deleteCustomer
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

/*
	 * 删除用户的方法
	 */
	void deleteCustomer(Integer id);
	

(2)对应映射文件当中创建对应的删除用户的SQL
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)


	<delete id="deleteCustomer" parameterType="int" >
		DELETE 
			FROM 
			`customer`
		WHERE
			cust_id = #{cust_id} ;
	</delete>

(3)对应CustomerService当中创建删除方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	/*
	 * 删除用户的方法
	 */
	void deleteCustomer(Integer id);

(4)对应CustomerService实现类当中调用删除方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	@Override
	public void deleteCustomer(Integer id) {
		customerMapper.deleteCustomer(id);
	}

(5)CustomerController控制器调用delete方法
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

	@RequestMapping("delete")
	@ResponseBody
	public String delete(Integer id) {
		String msg = "1";
		try {
			customerService.deleteCustomer(id);
			msg = "0";
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}

(6)运行并测试
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)
马云21消失了
SpringMVC+Mybatis,CRM系统教程和源代码(SSM项目)

上一篇:当下流行的后端框架


下一篇:MySQL常用命令