SpringMVC+Spring+Mybatis(SSM~Dem
SpringMVC+Spring+Mybatis 框架搭建
整个Demo的视图结构:
首先,我是使用MyEclipse工具做的这个例子,整合了Sping 3 、Spring MVC 3 、MyBatis框架,演示数据库采用MySQL数据库。例子中主要操作包括对数据的添加(C)、查找(R)、更新(U)、删除(D)。我在这里采用的数据库连接池是来自阿里巴巴的Druid,至于Druid的强大之处,我在这里就不做过多的解释了,有兴趣的朋友们可以去网上谷歌或者百度一下哦!好了下面我就贴上这次这个演示例子的关键代码:
example目录下是一个基本案例:
BaseController.java

1packagecom.talent.example.controller;2importjava.util.List;3importjava.util.UUID;4importjavax.servlet.http.HttpServletRequest;5importorg.springframework.beans.factory.annotation.Autowired;6importorg.springframework.stereotype.Controller;7importorg.springframework.web.bind.annotation.RequestMapping;89importcom.talent.example.model.Base;10importcom.talent.example.service.BaseService;11/**12*
Title:控制器Controller
13*
Description:
14*
Copyright: Copyright (c) VISEC 2015
15*
CreatTime: Mar 25 2015
16*@authorDana丶Li17*@version1.018*/19@Controller20publicclassBaseController {21privateBaseService baseService;22privatestaticString pathHead="ViewCenter/TalentBaseExample/";2324publicBaseService getBaseService(){25returnbaseService;26}27@Autowired28publicvoidsetBaseService(BaseService baseService){29this.baseService =baseService;30}3132@SuppressWarnings("finally")33@RequestMapping("addInfo")34publicString add(Base add,HttpServletRequest request){35try{36add.setId(UUID.randomUUID().toString());37//System.out.println(add.getId() + ":::::" + add.getTname() + ":::::" + add.getTpwd());38String str =baseService.addInfo(add);39//System.out.println(str);40request.setAttribute("InfoMessage", str);41}catch(Exception e){42e.printStackTrace();43//request.setAttribute("InfoMessage", "添加信息失败!具体异常信息:" + e.getMessage());44}finally{45returnBaseController.pathHead+"result";46}47}4849@RequestMapping("getAll")50publicString getBaseInfoAll(HttpServletRequest request){51try{52List list =baseService.getAll();53//System.out.println(list);54request.setAttribute("addLists", list);55returnBaseController.pathHead+"listAll";56}catch(Exception e){57e.printStackTrace();58//request.setAttribute("InfoMessage", "信息载入失败!具体异常信息:" + e.getMessage());59returnBaseController.pathHead+"result";60}61}6263@SuppressWarnings("finally")64@RequestMapping("del")65publicString del(String tid,HttpServletRequest request){66try{67String str =baseService.delete(tid);68request.setAttribute("InfoMessage", str);69}catch(Exception e) {70e.printStackTrace();71//request.setAttribute("InfoMessage", "删除信息失败!具体异常信息:" + e.getMessage());72}finally{73returnBaseController.pathHead+"result";74}75}76@RequestMapping("modify")77publicString modify(String tid,HttpServletRequest request){78try{79Base add =baseService.findById(tid);80request.setAttribute("add", add);81returnBaseController.pathHead+"modify";82}catch(Exception e){83e.printStackTrace();84//request.setAttribute("InfoMessage", "信息载入失败!具体异常信息:" + e.getMessage());85returnBaseController.pathHead+"result";86}
以上就是几个关键位置的代码,我全部贴出来了。至于配置文件什么的,由于时间原因没有贴出。如果大家要是感兴趣的话,可以下载我的这个演示项目包,里面的东西都齐全着,导入到MyEclipse上面直接部署到服务器上面就可以运行。数据库就是里面的那个.sql文件。建个库然后将数据导入就是。哦,对了。导完数据后,记得别忘了到config.properties里面去把数据库的连接信息换成你自己哦!
1. 使用阿里巴巴Druid连接池(高效、功能强大、可扩展性好的数据库连接池、监控数据库访问性能、支持Common-Logging、Log4j和JdkLog,监控数据库访问)
2. 提供高并发JMS消息处理机制
3. 所有功能模块化、所有模块服务化、所有服务原子化的方式,提供可拓展的服务模型,使程序稳定运行,永不宕机
4. 提供Wink Rest、Webservice服务,故可作为独立服务平台部署
框架整合:
Springmvc + Mybatis + Shiro(权限) + REST(服务) + WebService(服务) + JMS(消息) + Lucene(搜搜引擎) + Quartz(定时调度) + Bootstrap Html5(支持PC、IOS、Android)
框架简介:
项目Maven构建,真实大型互联网架构,做到高并发,大数据处理,整个项目使用定制化服务思想,提供模块化、服务化、原子化的方案,将功能模块进行拆分,可以公用到所有的项目中。架构采用分布式部署架构,所有模块进行拆分,使项目做到绝对解耦,稳定压倒一切~~
持续集成:
1. 我的待办工作流服务(提供Webservice服务)
2. 我的待办工作流集成JMS消息服务(支持高并发,可支持成千上万系统集成)
3. 我的任务提供Rest服务,完成日常的工作管理,通过定时调度平台,动态生成我的任务、循环周期任务、定时邮催提醒完成任务等
4. 文件上传、多线程下载服务化、发送邮件、短信服务化、部门信息服务化、产品信息服务化、信息发布服务化、我的订阅服务化、我的任务服务化、公共链接、我的收藏服务化等
系统模块:
1. 用户管理:
用户信息管理(添加、删除、修改、用户授权、用户栏目管理、查询等)
用户组管理(添加、删除、修改、用户组栏目授权,栏目授权、查询、用户组人员添加查询等)
用户角色管理(添加、删除、修改、用户角色授权、用户角色栏目信息查询设置等)
2. 文章管理:
栏目管理:查询无限极栏目树、创建无限极栏目树分类(导航栏目、图片列表栏目、文章列表栏目、文章内容栏目等)、删除、修改栏目信息。
文章管理:创建、删除、修改文章,多维度文章查询,包括已发布、未发布、所有文章等。文章富文本编辑器、文章多文件上传、文章状态控制等。
3. 系统设置:
数据字典管理:支持中、英文信息,支持无限级别分类配置,动态控制是否可用等。
部门信息管理:支持中、英文无限级别部门信息增加,删除,修改操作,部门列表、树心查询等。
日志管理:系统日志列表查询、在线查看、在线下载等
路线管理:集成百度地图API,提供线路查询管理功能
Druid Monitor(监控):集成阿里巴巴连接池,提供在线连接池监控程序,包括:数据源、SQL监控、URL监控、Session监控、Spring监控等
网站信息管理:通过系统配置文件进行网站内容操作,包括邮件服务器配置、公司基本信息配置等。
4.集成REST服务,可以用作独立服务平台(提供大量实例及测试平台,包括:文件上传下载、邮件短信发送、部门、产品、公共连接、我的收藏、我的任务、信息发布等)
5. 集成Quartz调度,可以用作定时调度平台(动态配置调度类、调度时间,使程序自动执行某些业务)
6. Lucene搜索引擎,可以将文件资料索引化,支持文件内容搜索、关键字搜索、高亮关键字等,使信息在毫秒内提取查询出来
7. 用户设置功能:包括修改用户信息,修改密码、发送消息,修改个人图片,查看角色、查看用户组,管理员修改角色、用户、用户组等。
8. 集成Webservice平台,包括jaxws服务、CXF框架,配置双加密的权限认证。使服务集成更加安全。
9. Bootstrap html5提供了两套前台开环境,包括CMS和电子商务网站,使您的开发更加的简洁。
技术点:
1. Springmvc + Mybatis集成、SpringSecurity权限控制、Spring AOP事务处理。
2. Wink Rest服务、Webservice服务:jaxws、CXF等
3. IO 流上传下载文件,多线程操作
4. 发送邮件,配置邮件服务器,发基于html、纯文本格式的邮件
5. MD5加密 (登陆密码校验加密等),用户统一Session、Cookie管理,统一验证码校验等。
6. 数据库连接池统一配置
7. Quartz定时调度任务集成(直接通过配置即可)
8. Httpclient破解验证码,登陆联通充值平台
9. 汉字、英文拆分、可以用作文档关键字搜索等。
10. Base64图片处理,支持PC,Android,IOS
11. Service Socket 、Client Socket 通信技术(已经做过GPRS数据获取,并用到了项目中)
12. 提供大量工具类,可以直接使用
13. Maven项目构建,您可以直接做架构,可以提升自己的学习能力,使您成为真正的架构师。




















































