一.配置文件
①主配置文件:applicationContext-auth.xml
<!-- 数据访问层配置 -->
<import resource="classpath:/META-INF/spring/springMVC-dao-auth.xml" />
<!--服务层配置 -->
<import resource="classpath:/META-INF/spring/springMVC-service-auth.xml" />
②数据层配置文件:springMVC-dao-auth.xml
<!-- 扫描com.ibs.gbplatform.dao包下所有标注@Repository的DAO组件 -->
<context:component-scan base-package="com.ibs.auth.dao.impl"/>
③服务层配置文件:springMVC-service-auth.xml
<!-- 扫描com.ibs.oa.biz.impl包下所有标注@Service的服务组件 -->
<context:component-scan base-package="com.ibs.auth.service.impl"/>
④servlert层配置文件:springMVC-servlet-auth.xml
<!-- 自动扫描com.ibs.**.controller 包下的@Controller标注的类控制器类 -->
<context:component-scan base-package="com.ibs.auth.controller" />
<mvc:annotation-driven />
二。注解
① @Controller //控制层
@RequestMapping(value="UserShowApp/")
通过路径找到方法。
@Autowired //自动注入,把Service层注入给Controller
private ModuleSecurityLevelConfigService moduleSecurityLevelConfigService;
@RequestMapping("/getList.html")//路径为:../../UserShowApp/getList.html
public void getList()
②@Service //服务层
@Transactional //事务的注解 。使增删改查具有事务性
public void updateUserOrder()
③@Repository //持久层
//定义命名名称
private static final String MAPPING = "com.ibs.auth.mapper.UserShowMapper";
super.update(MAPPING+".updateUserOrder", dataMap);
④Sqlmap层
<mapper namespace="com.ibs.auth.mapper.UserShowMapper"> //命名空间 也是访问路径
<resultMap type="com.ibs.auth.model.UserShow" id="resultMap"></resultMap>实体类(参数)
<select id="getList" resultType="com.ibs.auth.model.UserShow" parameterType="hashmap">
parameterType参数。resultType返回结果类型