您的位置:首页 > 编程语言 > Java开发

Spring MVC + Mybatis + Spring - 整合示例1:查询所有的客户信息

2016-01-06 08:50 731 查看

1.背景

   通过这么长时间的学习,终于见到了效果,确实有点乐不思蜀。虽然下面还有很多东西要学习,但是也要为自己的第一篇整合篇写下一些留念。

  数据库:Oracle xe10g

  表 : 客户信息表 

  场景描述:实现查询所有的客户信息;

  框架:Spring + Springmvc + Mybatis

  Spring的作用 :

                                      


   表现层:springMvc

   业务层:service接口

   持久层:mybatis

   数据库:Oracle / Mysql

   

    Spring将各层进行整合:
1) 通过Spring管理持久层的mapping(相当于dao接口)
2) 通过Spring管理业务层Service,Service中可以调用Mapping接口;可以进行事务控制(AOP)
3) 通过spring 管理表现层Handler,Handler中可以调用Service接口;
mapper,service,handler都是javabean ;

2.示例实现 

  2.1 最终效果

 


  2.2 数据准备

     (1)创建客户信息表

CREATE TABLE F_CLIENT(
ID NUMBER(12) PRIMARY KEY,--用户编号
USERNAME VARCHAR2(20) NOT NULL,--用户姓名
CLIENT_CERTIFICATE_NO VARCHAR2(20) NOT NULL UNIQUE,--证件号码
BORN_DATE DATE,--出生日期
FAMILY_REGISTER_ADDRESS VARCHAR2(200),--家庭住址
NOW_ADDRESS VARCHAR2(200) NOT NULL,--现在住址
CONTACT_MODE VARCHAR2(50) NOT NULL,--联系方式
URGENCY_CONTACT_MODE VARCHAR2(50) NOT NULL,--紧急联系方式
CREATE_DATE DATE NOT NULL--创建时间
);

    (2)添加客户信息
insert into f_client(id,username,client_certificate_no,born_date,family_register_address,now_address,contact_mode,urgency_contact_mode,create_date) values (14,
'yuan','311209070127',to_date('1993-03-12','yyyy-mm-dd'),'河南省焦作市','河南省河南理工大学','150000000','110',sysdate);
insert into f_client(id,username,client_certificate_no,born_date,family_register_address,now_address,contact_mode,urgency_contact_mode,create_date) values(
15,'yang','311209070126',to_date('1993-04-12','yyyy-mm-dd'),'河南温县','河南理工大学','3987321','110',sysdate);
insert into f_client values(
16,'yang','311209070129',to_date('1997-04-12','yyyy-mm-dd'),'河南新乡','河南理工大学','3987321','110',sysdate);

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (1, 'sawyer', '1593224056', to_date('10-10-1980', 'dd-mm-yyyy'), '北京市海淀区东北旺', 'peaking', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (2, 'yangly', '1593224057', to_date('11-10-1980', 'dd-mm-yyyy'), '北京市海淀区东北旺', 'peaking', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (3, 'gaozhy', '1593224058', to_date('12-12-1980', 'dd-mm-yyyy'), '湖北省洪山区黄家湖', 'shanghai', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (4, 'wangmj', '1593224059', to_date('13-04-1980', 'dd-mm-yyyy'), '湖北省洪山区黄家湖', 'hubei', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (5, 'lijing', '1593224060', to_date('14-07-1980', 'dd-mm-yyyy'), '湖北省洪山区黄家湖', 'tianjing', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (6, 'wangpl', '1593224061', to_date('15-09-1980', 'dd-mm-yyyy'), '北京市朝阳区百子湾', 'peaking', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (7, 'lixiao', '1593224062', to_date('16-09-1980', 'dd-mm-yyyy'), '北京市朝阳区百子湾', 'henan', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (8, 'zhaoyf', '1593224063', to_date('17-07-1980', 'dd-mm-yyyy'), '北京市海淀区五道口', 'henan', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (9, 'suyibo', '1593224064', to_date('18-09-1980', 'dd-mm-yyyy'), '北京市海淀区东北旺', 'hebei', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (10, 'luojh', '1593224065', to_date('19-09-1980', 'dd-mm-yyyy'), '北京市朝阳区百子湾', 'heilongjiang', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (11, 'mazhb', '1593224066', to_date('10-08-1980', 'dd-mm-yyyy'), '北京市海淀区东北旺', 'peaking', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (12, 'gaohf', '1593224067', to_date('18-08-1980', 'dd-mm-yyyy'), '北京市朝阳区百子湾', 'peaking', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));

insert into F_CLIENT (ID, USERNAME, CLIENT_CERTIFICATE_NO, BORN_DATE, FAMILY_REGISTER_ADDRESS, NOW_ADDRESS, CONTACT_MODE, URGENCY_CONTACT_MODE, CREATE_DATE)
values (13, 'chenb', '1593224068', to_date('13-08-1980', 'dd-mm-yyyy'), '北京市海淀区西二旗', 'peaking', '123456789', '987654321', to_date('15-12-2015 08:47:13', 'dd-mm-yyyy hh24:mi:ss'));


  2.3 Mybatis 实现

     (1)Mapper.java实现

/**
* 客户信息Dao
* TODO
* 作者:原明卓
* 时间:2016年1月5日 上午9:03:16
* 工程:SpringMvcMybatis1Demo
*/
public interface FClientMapper {

//根据id查询用户信息
FClient findClientById(int id) throws Exception;
//获得所有用户信息
List<FClient> findClientList() throws Exception;
//更新新客户信息
int updateClientIfo(FClient fc) throws Exception;
//删除客户信息
int deleteClientIfo(int id) throws Exception;
//新增客户信息
int insertClientIfo(FClient fc) throws Exception;

}


   (2)Mapper.xml实现
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.labelnet.ssm.mapper.FClientMapper">

<!-- 根据id查询用户信息 -->
<select id="findClientById" parameterType="int" resultType="fclient">
select * from f_client
<where>
id=#{id}
</where>
</select>

<!-- 获得所有用户信息 -->
<select id="findClientList" resultType="fclient">
select * from f_client order by id asc
</select>

<!-- 更新新客户信息 -->
<update id="updateClientIfo" parameterType="fclient" >
update
f_client
<set>
username=#{username},
client_certificate_no=#{client_certificate_no},
born_date=#{born_date},
family_register_address=#{family_register_address},
now_address=#{now_address},
contact_mode=#{contact_mode},
urgency_contact_mode=#{urgency_contact_mode}
</set>
<where>
id=#{id}
</where>
</update>

<!-- 删除客户信息 -->
<delete id="deleteClientIfo" parameterType="int">
delete from f_client where id=#{id}
</delete>

<!-- 新增客户信息 -->
<insert id="insertClientIfo" parameterType="fclient">
insert into
f_client
values(
#{id},
#{username},
#{client_certificate_no},
#{born_date},
#{family_register_address},
#{now_address},
#{contact_mode},
#{urgency_contact_mode},
sysdate)
</insert>

</mapper>

   (3)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>

<!-- 别名 -->
<typeAliases>

<typeAlias type="cn.labelnet.ssm.po.FClient" alias="fclient"/>

</typeAliases>

<mappers>

<!-- 采用类扫描的方式加载mapper文件 -->
<!-- <package name="cn.labelnet.ssm.mapper"/> -->

</mappers>

</configuration>

   (4)Mybatis与Spring整合 :实现ApplicationContext-dao.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 1.配置数据库数据源, 配置sqlSessionFactory -->
<context:property-placeholder location="classpath:db.properties"/>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.name}"></property>
<property name="password" value="${jdbc.pass}"></property>
<property name="maxActive" value="10"></property>
<property name="maxIdle" value="5"></property>
</bean>

<!-- 配置SqlSessionFactroy-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis/sqlmapConfig.xml"></property>
<property name="dataSource" ref="dataSource"></property>
</bean>

<!-- 采用mapper扫描方式 ,加载mapper , id为扫描到的mapper.java的类名,首字母小写-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.labelnet.ssm.mapper"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>

</beans>

     (5)数据库配置 db.properties
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
jdbc.name=hr
jdbc.pass=hr

2.4 Service实现

   (1)Service接口

public interface FClientService {

//根据id查询用户信息
FClient findClientById(int id) throws Exception;
//获得所有用户信息
List<FClient> findClientList() throws Exception;
//更新新客户信息
String updateClientIfo(FClient fc) throws Exception;
//删除客户信息
String deleteClientIfo(int id) throws Exception;
//新增客户信息
String insertClientIfo(FClient fc) throws Exception;

}   (2)Service 接口实现
/**
* 接口实现
* TODO
* 作者:原明卓
* 时间:2016年1月5日 上午9:05:20
* 工程:SpringMvcMybatis1Demo
*/
public class FClientServiceImpl implements FClientService{

//Mapper
@Autowired
private FClientMapper fcmapper;

@Override
public FClient findClientById(int id) throws Exception {
return fcmapper.findClientById(id);
}

@Override
public List<FClient> findClientList() throws Exception {
return fcmapper.findClientList();
}

@Override
public String updateClientIfo(FClient fc) throws Exception {
return fcmapper.updateClientIfo(fc)>0?"success":"failed";
}

@Override
public String deleteClientIfo(int id) throws Exception {
return fcmapper.deleteClientIfo(id)>0?"success":"failed";
}

@Override
public String insertClientIfo(FClient fc) throws Exception {
return fcmapper.insertClientIfo(fc)>0?"success":"failed";
}

}

   (3)Service 与 Spring 整合 :实现ApplicationContext-service.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="fclientService" class="cn.labelnet.ssm.service.impl.FClientServiceImpl"></bean>


     (4)Service中使用Spring进行事务控制 :ApplicationContext-transcation.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 事务控制管理,使用Spring下的jdbc进行管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<property name="dataSource" ref="dataSource"></property>
</bean>

<!-- 通知 -->
<tx:advice id="txManager" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>

<!-- aop -->
<aop:config>
<aop:pointcut expression="execution(* cn.labelnet.ssm.service.impl.*.*(..))" id="perfrom"/>
<aop:advisor advice-ref="txManager" pointcut-ref="perfrom"/>
</aop:config>

</beans>

2.5 SpringMVC实现

    (1)Handler实现

package cn.labelnet.ssm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.labelnet.ssm.po.FClient;
import cn.labelnet.ssm.service.FClientService;

/**
* TODO 作者:原明卓 时间:2016年1月5日 下午3:23:11 工程:SpringMvcMybatis1Demo
*/
@Controller
public class FClientController {

@Autowired
private FClientService fcService;

@RequestMapping("/clientslist")
public ModelAndView clientsList(){

ModelAndView view=new ModelAndView();
List<FClient> list;
try {
list = fcService.findClientList();

view.addObject("clients",list);
view.setViewName("clientindex.jsp");
} catch (Exception e) {
view.addObject("error",e.getMessage());
view.setViewName("error.jsp");
}
return view;
}

}


   (2)SpringMvc.xml 实现 - 注解实现
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> 
<!-- 配置Handler:扫描的方式 -->
<context:component-scan base-package="cn.labelnet.ssm.controller"></context:component-scan>

<!-- 注解映射器 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"></bean>
<!-- 注解适配器 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"></bean>

<!-- 使用Mvc:annotation-driven代替上面的注解映射器和适配器
mvc:annotation-driver默认加载很多的参数绑定方法;
那样就不用配置上班的requestMappingHandlerMapping和RequestMappingHandlerAdapter了
推荐使用;<mvc:annotation-driven></mvc:annotation-driven>
-->

<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" />

</beans>


   (3)web.xml - SpringMvc 配置, 加载Spring容器
           加载Spring容器采用通配符的方式实现,使得可以拓展;

<!-- 加载spring容器:采用通配符的方式实现 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- 配置Springmvc 处理器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>

2.6 Jsp页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>客户信息表</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
body{
background-image: url("http://img.taopic.com/uploads/allimg/120427/53163-12042G0331866.jpg");
}
</style>
</head>

<body>
<h1>客户信息管理</h1>

<form method="post" action="" style="margin-top: 10px;float: left;margin-left: 5%;">
<input id="search" type="text" >
<input value="查询" type="submit">
</form>
<table width="90%" border="1" align="center">
<thead>
<tr>
<td colspan="10" align="center"> 客户信息管理</td>
</tr>
</thead>
<tbody>
<tr align="center">
<td>编号</td>
<td>姓名</td>
<td>代码</td>
<td>生日</td>
<td>家庭住址</td>
<td>现居住地</td>
<td>联系方式</td>
<td>紧急联系方式</td>
<td>注册日期</td>
<td>操作</td>
</tr>
<c:forEach items="${clients}" var="c">

<tr>
<td> ${c.id} </td>
<td> ${c.username} </td>
<td> ${c.client_certificate_no} </td>
<td> ${c.born_date} </td>
<td> ${c.family_register_address} </td>
<td> ${c.now_address} </td>
<td> ${c.contact_mode} </td>
<td> ${c.urgency_contact_mode} </td>
<td> ${c.create_date} </td>
<td><a href="">查看</a></td>
</tr>

</c:forEach>
</tbody>
</table>
</body>
</html>


 

2.7 测试部署

    测试的话,访问Handler中的RequestMapping("")  中的url地址 ,比如 :
http://localhost:8989/SpringMvcMybatis1Demo/clientslist.action
      

3.总结

   首先是Mybatis的实现,在实现的时候,每做一个方法,测试一个方法,以保证正确性;其次在配置SpringMvc和加载Spring容器的时候,采用通配符的方式实现,以保证拓展性;最后,MVC中实现Handler的时候,采用注解的方式,方便开发,一个类中可以写多个方法实现;

   在这个例子 中,还有很多功能需要完善,比如查询,分页,修改,删除,都是需要实现的;如果类比Asp.net MVC的话,那么Handler的返回值,参数等都需要学习;

 

4.demo免积分下载

http://download.csdn.net/detail/lablenet/9392008
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息