1、dao层
1.1、必须数据:
pojo(java实体)、mapper接口(dao接口)、sql映射文件(翻译为jdbc中的statement)
1.2、配置文件:
mybatis核心配置文件:SqlMapConfig.xml
自定义别名
spring整合mybatis配置文件:applicationContext-dao.xml
数据源
会化工厂
mapper扫描(加载dao)
其他配置:
数据库信息:db.properties
日志信息:log4j.properties
2、service层
2.1、配置文件:
注解扫描:@service(加载service)applicationContext-service.xml
事务配置: ApplicationContext-trans.xml
3、controller层
3.1、配置文件: springMVC.xml
注解扫描:@controller(加载controller)
注解驱动:自动加载最新的处理器映射器、处理器适配器
视图解析器:
自定义类型转化器:(挂载于注解驱动)
文件上传解析器:
json格式数据解析器:(若没有配置注解驱动,则需要显示的在处理器适配器挂载)
全局异常处理器:
自定义拦截器:
静态资源放行:
4、web.xml web.xml
4.1、spring监听器
4.2、springMVC前端控制器
4.3、post中文乱码请求
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>
<properties resource="db.properties"></properties>
<typeAliases>
<!-- 定义单个pojo类别名
type:类的全路劲名称
alias:别名
-->
<!-- <typeAlias type="xx.xxxx.pojo.User" alias="user"/> -->
<!-- 使用包扫描的方式批量定义别名
定以后别名等于类名,不区分大小写,但是建议按照java命名规则来,首字母小写,以后每个单词的首字母大写
-->
<package name="xx.xxx.pojo"/>
</typeAliases>
</configuration>
applicationContext-dao.xml
<beansxmlns="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-placeholderlocation="classpath:jdbc.properties"/>
<!-- 配置 数据源 -->
<beanid="dataSource"class="com.alibaba.druid.pool.DruidDataSource">
&