SpringMVC关于ajax+Spring+MyBatis整合概述

1.前期工作
    1.1 数据库建表;
    1.2 新建工程;

    1.3 引入MyBatis-Spring,MyBatis,Spring包;


2.MyBatis相关
    2.1 建对应表的实体类(Entity);
    2.2 建mapper映射器接口(XxxMapper.java);
    2.3 建mapper映射器xml(XxxMapper.xml与映射器接口同名),指定namespace到映射器接口;
    2.4 建Mybatis配置文件mybatis-config.xml,引入mapper映射器xml文件;
        2.4.1 如果mapper映射器xml较多,并且位置分散,适合把mapper映射器xml配置到mybatis-config.xml中,再在SqlSessionFactory的configLocation属性中配置mybatis-config.xml;

        2.4.2 如果mybatis-config.xml只是用来配置mapper映射器xml文件,而全部mapper映射器xml可以采用"**/*.xml"配置在Spring配置文件的SqlSessionFactory的mapperLocations属性里,那么mybatis-config.xml可以省略;


3.Spring相关
    3.1 在web.xml配置Spring的DispatcherServlet,并指定Spring配置文件applicationContext.xml;
    3.2 配置Srping配置文件applicationContext.xml(重点),主要有:
        3.2.1 context:component-scan
        3.2.2 context:property-placeholder (定义属性占位符的属性配置文件)
        3.2.3 mvc:annotation-driven
        3.2.4 DataSource
        3.2.5 SqlSessionFactory
            3.2.5.1 configLocation属性,配置mybatis-config.xml;
                如果mybatis-config.xml配置了所有Mybatis映射器xml,并且configLocation属性配置mybatis-config.xml,则SqlSessionFactory的mapperLocations属性不用配置;
            3.2.5.2 mapperLocations属性配置Mybatis映射器xml文件;
                如果SqlSessionFactory的mapperLocations属性配置了所有mapper映射器xml文件,而mybatis-config.xml又没有其它配置,那么mybatis-config.xml可以省略,SqlSessionFactory的configLocation属性也不用配置;
            3.2.5.3 typeAliasesPackage属性注册实体类别名;
        3.2.6 TransactionManager
        3.2.7 MapperFactoryBean
        3.2.8 ServiceBean

        3.2.9 ViewResolver


4.编写Service;


5.编写Controller;


6.前端页面编写;

    6.1 编写ajax,发起匹配控制器@RequestMapping一致的URL请求;

          (前端开发推荐采用阿里巴巴的BUI前端框架)



  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值