web.xml配置文件:略
Struts2配置文件:略
Ibatis配置文件:
SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<sqlMap resource=com/wh/model/user.xml"/>
</sqlMapConfig>
orm映射文件:略
Spring配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byType"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">
<property name="driverClassName"value="com.mysql.jdbc.Driver" />
<property name="url"value="jdbc:mysql://127.0.0.1:3306/test"/>
<property name="username"value="root" />
<property name="password"value="toor" />
</bean>
<bean id="client"class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<!-- 继承 org.springframework.orm.ibatis.support.SqlMapClientDaoSupport 有个sqlMapClient的属性 -->
<bean id="userDao"
class="com.wh.dao.UserDAO">
<property name="sqlMapClient"ref="client" />
</bean>
<bean id="userBiz"
class="com.wh.biz.UserBiz">
<property name="userDAO"ref="userDao"></property>
</bean>
<bean id="UserAction"class="com.wh.action.UserAction">
<property name="userBiz"ref="userBiz"></property>
</bean>
</beans>