码迷,mamicode.com
首页 > 其他好文 > 详细

ssm整合案例

时间:2018-03-27 18:43:26      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:navicat   www   邮政编码   dex   springmvc   big   action   sep   .so   

简单CRM系统实现

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);
sql语句

1、创建crm数据库

2、将sql脚本导入到数据库中

2 工程搭建

工程使用springmvc、 spring、mybatis框架整合完成。

2.1、创建package和导包

包结构示意图:

技术分享图片

导入jar包:

技术分享图片

pojo实体类:

技术分享图片
package com.ssm.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 Integer 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 Integer getDict_sort() {
        return dict_sort;
    }

    public void setDict_sort(Integer 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;
    }

}
BaseDict.java
技术分享图片
package com.ssm.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;
    }
    
}
Customer.java
技术分享图片
package com.ssm.crm.pojo;

public class QueryVo {

    private String custName;
    private String custSource;
    private String custIndustory;
    private String custLevel;
    private Integer page = 1;
    private Integer start;
    private Integer size = 10;
    public Integer getStart() {
        return start;
    }
    public void setStart(Integer start) {
        this.start = start;
    }
    public Integer getPage() {
        return page;
    }
    public void setPage(Integer page) {
        this.page = page;
    }
    public Integer getSize() {
        return size;
    }
    public void setSize(Integer size) {
        this.size = size;
    }
    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 getCustIndustory() {
        return custIndustory;
    }
    public void setCustIndustory(String custIndustory) {
        this.custIndustory = custIndustory;
    }
    public String getCustLevel() {
        return custLevel;
    }
    public void setCustLevel(String custLevel) {
        this.custLevel = custLevel;
    }
    
}
QueryVo.java

2.2 SqlMapConfig.xml

<?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.3 applicationContext-dao.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:task="http://www.springframework.org/schema/task" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    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 
        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/task
           http://www.springframework.org/schema/task/spring-task-4.0.xsd
        http://code.alibabatech.com/schema/dubbo        
        http://code.alibabatech.com/schema/dubbo/dubbo.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}" />
        <!-- url -->
        <property name="url" value="${jdbc.url}" />
        <!-- 用户名 -->
        <property name="username" value="${jdbc.username}" />
        <!-- 密码 -->
        <property name="password" value="${jdbc.password}" />
    </bean>

    <!-- 配置 Mybatis的工厂 -->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 数据源 -->
        <property name="dataSource" ref="dataSource" />
        <!-- 配置Mybatis的核心 配置文件所在位置 -->
        <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
        <!-- 配置pojo别名 -->
        <property name="typeAliasesPackage" value="com.ssm.crm.pojo"></property>
    </bean>

    <!-- 配置 1:原始Dao开发 接口实现类 Mapper.xml 三个 2:接口开发 接口 不写实现类 Mapper.xml 二个 (UserDao、ProductDao 
        、BrandDao。。。。。。。) 3:接口开发、并支持扫描 cn.itcast.core.dao(UserDao。。。。。) 写在此包下即可被扫描到 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.ssm.crm.mapper" />
    </bean>

</beans>

jdbc.properties

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

2.3 applicatiin-service.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    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 
        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/task
           http://www.springframework.org/schema/task/spring-task-4.0.xsd
        http://code.alibabatech.com/schema/dubbo        
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
        
        
        <!-- 配置  扫描   @Service -->
        <context:component-scan base-package="com.ssm.crm.service"/>                        
</beans>

2.4 applicationContext-trans.xml

 

<?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:attributes>
    </tx:advice>
    <!-- 切面 -->
    <aop:config>
        <aop:advisor advice-ref="txAdvice"
            pointcut="execution(* com.ssm.crm.service.*.*(..))" />
    </aop:config>
</beans>

2.5 Springmvc.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
    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 
        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/task
           http://www.springframework.org/schema/task/spring-task-4.0.xsd
        http://code.alibabatech.com/schema/dubbo        
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
        
        <!-- 加载属性文件 -->
        <context:property-placeholder location="classpath:resource.properties"/>
        <!-- 配置扫描 器 -->
        <context:component-scan base-package="com.ssm.crm.controller"/>
        <!-- 配置处理器映射器  适配器 -->
        <mvc:annotation-driven/>
        
        <!-- 配置视图解释器 jsp -->
        <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/jsp/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
        
</beans>

2.6 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <welcome-file-list>
        <welcome-file>customer.action</welcome-file>
    </welcome-file-list>
    <!-- 上下文的位置 -->
    <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提交过滤器 UTF-8 -->
    <filter>
        <filter-name>encoding</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>encoding</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <!-- 前端控制器 -->
    <servlet>
        <servlet-name>crm</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <!-- 此处不配置 默认找 /WEB-INF/[servlet-name]-servlet.xml -->
            <param-value>classpath:spring/springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>crm</servlet-name>
        <!-- 1:*.do *.action 拦截以.do结尾的请求 (不拦截 jsp png jpg .js .css) 2:/ 拦截所有请求 
            (不拦截.jsp) 建议使用此种 方式 (拦截 .js.css .png) (放行静态资源) 3:/* 拦截所有请求(包括.jsp) 此种方式 不建议使用 -->
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>
</web-app>
<load-on-startup>1</load-on-startup>

当值为0或者大于0时,表示容器在应用启动时就加载这个servlet;

当是一个负数时或者没有指定时,则指示容器在该servlet被选择时才加载。

正数的值越小,启动该servlet的优先级越高

2.7 加入jsp及分页标签

 技术分享图片

自定义标签需要继承TagSupport,重写doStartTag方法,在方法里实现业务需求。

技术分享图片
package com.ssm.crm.utils;

import java.io.IOException;
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;
            if (value.getClass().isArray()) {
                url = append(url, key.toString(), ((String[]) value)[0]);
            } else if (value instanceof String) {
                url = append(url, key.toString(), value.toString());
            }
        }
        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;
    }

}
NavigationTag

自定义pojo类(分页page)

技术分享图片
package com.ssm.crm.utils;

import java.util.List;

public class Page<T> {
    
    private int total;
    private int page;
    private int size;
    private List<T> 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;
    }       
}
Page分页

自定义tld

技术分享图片
<?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://ssm/crm/common/</uri>
    <display-name>Common Tag</display-name>
    <description>Common Tag library</description>

    <tag>
        <name>page</name>
        <tag-class>com.ssm.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>
commons.tld

 jsp页面

<%@ 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="ssm" uri="http://ssm/crm/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="${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 == 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="custIndustory">
                                <option value="">--请选择--</option>
                                <c:forEach items="${industoryType}" 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 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 == 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">
                            <ssm: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){
                alert("客户信息更新成功!");
                window.location.reload();
            });
        }
        
        function deleteCustomer(id) {
            if(confirm(‘确实要删除该客户吗?‘)) {
                $.post("<%=basePath%>customer/delete.action",{"id":id},function(data){
                    alert("客户删除更新成功!");
                    window.location.reload();
                });
            }
        }
    </script>

</body>

</html>

 

查看页面效果

技术分享图片

完成下拉刷新列表操作

dao层开发:

技术分享图片
package com.ssm.crm.mapper;

import java.util.List;

import com.ssm.crm.pojo.BaseDict;

public interface BaseDictMapper {
    List<BaseDict> getDictListByTypeCode(String typeCode);
}
BaseDictMapper.java
技术分享图片
<?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.ssm.crm.mapper.BaseDictMapper">

    <select id="getDictListByTypeCode" parameterType="string" resultType="BaseDict">
        select * from base_dict where dict_type_code = #{typeCode}
    </select>
</mapper>
BaseDictMapper.xml

service层:

package com.ssm.crm.service.impl;

import java.util.List;

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

import com.ssm.crm.mapper.BaseDictMapper;
import com.ssm.crm.pojo.BaseDict;
import com.ssm.crm.service.BaseDictservice;

@Service
public class BaseDictServiceImpl implements BaseDictservice {

    @Autowired
    private BaseDictMapper mapper;
    @Override
    public List<BaseDict> getBaseDictByTypeCode(String typeCode) {
        
        return mapper.getDictListByTypeCode(typeCode);
    }

}

 controller层

package com.ssm.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.ssm.crm.pojo.BaseDict;
import com.ssm.crm.service.BaseDictservice;

@Controller
public class CustomerController {
    
    @Autowired
    private BaseDictservice dictservice;
    
    @Value("${customer.source.code}")
    private String custSourceCode;
    @Value("${customer.industory.code}")
    private String custIndustoryCode;
    @Value("${customer.level.code}")
    private String custLevelCode;
    
    @RequestMapping("/customer/list")
    public String showCostomerList(Model model){
        
        //初始化客户来源
        List<BaseDict> sourceList = dictservice.getBaseDictByTypeCode(custSourceCode);
        //所属行业
        List<BaseDict> industoryList = dictservice.getBaseDictByTypeCode(custIndustoryCode);
        //客户级别
        List<BaseDict> levelList = dictservice.getBaseDictByTypeCode(custLevelCode);
        
        model.addAttribute("fromType", sourceList);
        model.addAttribute("industoryType", industoryList);
        model.addAttribute("levelType", levelList);
        return "customer";        
    }
    
}

配置resource.properties文件(typeCode的字段值抽离代码,方便日后修改)

customer.source.code=002
customer.industory.code=001
customer.level.code=006

在springmvc中加载配置文件resource.properties

技术分享图片

测试:

技术分享图片

点击下拉框,可以加载出信息。

 查询客户信息(动态条件查询)

 新建一个pojo用于接收来自页面的条件,并封装成pojo类

package com.ssm.crm.pojo;

public class QueryVo {

    private String custName;
    private String custSource;
    private String custIndustory;
    private String custLevel;
    private Integer page = 1;
    private Integer start;
    private Integer size = 10;
    public Integer getStart() {
        return start;
    }
    public void setStart(Integer start) {
        this.start = start;
    }
    public Integer getPage() {
        return page;
    }
    public void setPage(Integer page) {
        this.page = page;
    }
    public Integer getSize() {
        return size;
    }
    public void setSize(Integer size) {
        this.size = size;
    }
    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 getCustIndustory() {
        return custIndustory;
    }
    public void setCustIndustory(String custIndustory) {
        this.custIndustory = custIndustory;
    }
    public String getCustLevel() {
        return custLevel;
    }
    public void setCustLevel(String custLevel) {
        this.custLevel = custLevel;
    }
}

新建CustomerMapper.java

package com.ssm.crm.mapper;

import java.util.List;

import com.ssm.crm.pojo.Customer;

public interface CustomerMapper {
    List<Customer>  getCustomerList();
}

新建CustomerMapper.xml

<?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.ssm.crm.mapper.CustomerMapper">
    <sql id="customer_list_where">
        <where>
            <if test="custName !=null and custName != ‘‘">
                and cust_name LIKE ‘%${custName}%‘
            </if>
            <if test="custSource !=null and custSource != ‘‘">
                AND cust_source = #{custSource}
            </if>
            <if test="custIndustory !=null and custIndustory != ‘‘">
                AND cust_industry = #{custIndustory}
            </if>
            <if test="custLevel !=null and custLevel != ‘‘">
                AND cust_level = #{custLevel}
            </if>
        </where>
    </sql>
    <select id="getCustomerList" parameterType="queryvo" resultType="customer">
        SELECT
            a.cust_id,
            a.cust_name,
            a.cust_user_id,
            a.cust_create_id,
            b.dict_item_name cust_source,
            c.dict_item_name cust_industry,
            d.dict_item_name cust_level,
            a.cust_linkman,
            a.cust_phone,
            a.cust_mobile,
            a.cust_zipcode,
            a.cust_address,
            a.cust_createtime
        FROM
            customer a
        LEFT JOIN base_dict b ON a.cust_source = b.dict_id
        LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
        LEFT JOIN base_dict d ON a.cust_level = d.dict_id
        <include refid="customer_list_where"/>
        <if test="start != null">
            limit #{start},#{size}
        </if>
    </select>
    <select id="getCustomerListCount" parameterType="queryvo" resultType="int">
        SELECT count(0)
        FROM
            customer a
        LEFT JOIN base_dict b ON a.cust_source = b.dict_id
        LEFT JOIN base_dict c ON a.cust_industry = c.dict_id
        LEFT JOIN base_dict d ON a.cust_level = d.dict_id
        <include refid="customer_list_where"/>
    </select>
    <select id="getCustomerById" parameterType="long" resultType="customer">
        SELECT *
        FROM
            customer 
        where cust_id = #{id}
    </select>
    <update id="updateCustomer" parameterType="customer">
        update customer
        <set>
            <if test="cust_name!=null">
                cust_name=#{cust_name},
            </if>
            <if test="cust_user_id!=null">
                cust_user_id=#{cust_user_id},
            </if>
            <if test="cust_create_id!=null">
                cust_create_id=#{cust_create_id},
            </if>
            <if test="cust_source!=null">
                cust_source=#{cust_source},
            </if>
            <if test="cust_industry!=null">
                cust_industry=#{cust_industry},
            </if>
            <if test="cust_level!=null">
                cust_level=#{cust_level},
            </if>
            <if test="cust_linkman!=null">
                cust_linkman=#{cust_linkman},
            </if>
            <if test="cust_phone!=null">
                cust_phone=#{cust_phone},
            </if>
            <if test="cust_mobile!=null">
                cust_mobile=#{cust_mobile},
            </if>
            <if test="cust_zipcode!=null">
                cust_zipcode=#{cust_zipcode},
            </if>
            <if test="cust_address!=null">
                cust_address=#{cust_address},
            </if>
            <if test="cust_createtime!=null">
                cust_createtime=#{cust_createtime},
            </if>
        </set>
        WHERE cust_id=#{cust_id}
    </update>
    <delete id="deleteCustomer" parameterType="long">
        DELETE
        FROM
            customer
        WHERE
            cust_id = #{id}
    </delete>
</mapper>

Customerservice层代码

package com.ssm.crm.service.impl;

import java.util.List;

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

import com.ssm.crm.mapper.CustomerMapper;
import com.ssm.crm.pojo.Customer;
import com.ssm.crm.pojo.QueryVo;
import com.ssm.crm.service.CustomerService;
import com.ssm.crm.utils.Page;

@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerMapper mapper;
    @Override
    public Page<Customer> getCustomerList(QueryVo queryVo) {
        //计算分页起始记录
        if (queryVo.getPage()!=null) {
            queryVo.setStart((queryVo.getPage()-1)*queryVo.getSize());
        }
        List<Customer> list = mapper.getCustomerList(queryVo);
        //创建一个page对象
        Page<Customer> page = new Page<>();
        page.setRows(list);
        page.setSize(queryVo.getSize());
        page.setPage(queryVo.getPage());
        //查询总记录数
        Integer count = mapper.getCustomerListCount(queryVo);
        page.setTotal(count);
        return page;
    }

}

Controller层代码

package com.ssm.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.ssm.crm.pojo.BaseDict;
import com.ssm.crm.pojo.Customer;
import com.ssm.crm.pojo.QueryVo;
import com.ssm.crm.service.BaseDictservice;
import com.ssm.crm.service.CustomerService;
import com.ssm.crm.utils.Page;

@Controller
public class CustomerController {
    
    @Autowired
    private BaseDictservice dictservice;
    @Autowired
    private CustomerService customerService;
    
    @Value("${customer.source.code}")
    private String custSourceCode;
    @Value("${customer.industory.code}")
    private String custIndustoryCode;
    @Value("${customer.level.code}")
    private String custLevelCode;
    
    @RequestMapping("/customer/list")
    public String showCostomerList(QueryVo queryVo,Model model){
        
        //初始化客户来源
        List<BaseDict> sourceList = dictservice.getBaseDictByTypeCode(custSourceCode);
        //所属行业
        List<BaseDict> industoryList = dictservice.getBaseDictByTypeCode(custIndustoryCode);
        //客户级别
        List<BaseDict> levelList = dictservice.getBaseDictByTypeCode(custLevelCode);
        
        model.addAttribute("fromType", sourceList);
        model.addAttribute("industoryType", industoryList);
        model.addAttribute("levelType", levelList);
        //根据查询条件查询客户
        Page<Customer> page = customerService.getCustomerList(queryVo);
        //把客户列表传递给页面
        model.addAttribute("page", page);
        return "customer";        
    }
    
}

页面效果:

技术分享图片

修改客户资料

 点击修改,弹出修改窗口,并且回显客户信息

技术分享图片

 

ssm整合案例

标签:navicat   www   邮政编码   dex   springmvc   big   action   sep   .so   

原文地址:https://www.cnblogs.com/lxk233/p/8531560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!