SSM搭建流程
集成步骤
集成准备:
1.创建web工程day041-ssm,注意classes在WEB-INF,修改编译路径
2.部署项目:将工程根目录复制到server.xml
3.创建index.jsp并测试
4.导包:day041/ssmJAR包集合
Spirng:
1.检查Springja包是否导入
2.创建资源文件目录Source Fold[resources]
3.创建Spring的配置文件applicationContext.xml
4.将当前系统时间交给Spring管理
5.使用spring测试是否配置正确
Spring+Mybatis:
1.创建数据库ssm
2.导入ssm.sql[课件-resources-随堂资源-ssm.sql]
3.编写属性文件jdbc.properties[资源文件resource中]
4.将属性文件交给spring管理
A.以前是将属性文件交给mybatis管理的
B.整合了mybatis之后,以前在mybatis中的配置信息全都要移植到spring中
5.spring管理数据BasicDataSource
6.测试BasicDataSource对象
7.编写实体类Emp[包:cn.itsource.domian]
8.创建EmpMapper接口[包:cn.itsource.mapper]
9.配置mapper映射文件 EmpMapper.xml
10.Spring管理SqlSessionFactory
11.测试SqlSessionFactory
12.Spring管理Mapper接口
`13.测试mapper
13.写service层
在applicationContext.xml中配置扫描
1.Spring+Mybatis+SpringMvc
1.web.xml配置前端控制器:加载spring–mvc-.xml ;过滤器解决post请求的中文参数乱码
2.编写Controller
3.在web.xml中通过web监听器加载applicationContext.xml