springmvc.xml
<context:component-scan base-package="com.smc.controller"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven></beans>
web.xm
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring.xml;classpath*:spring-mybatis.xml
</param-value>
</context-param>
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springServlet-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
spring -mybatis.xml
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config.properties</value>
</list>
</property>
</bean>
<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.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<!-- Connection Pooling Info -->
<!-- <property name="maxActive" value="${dbcp.maxActive}" /> <property
name="maxIdle" value="${dbcp.maxIdle}" /> <property name="defaultAutoCommit"
value="false" /> Á¬œÓIdleÒ»žöСʱºó³¬Ê± <property name="timeBetweenEvictionRunsMillis"
value="360000" /> <property name="minEvictableIdleTimeMillis" value="360000"
/> -->
</bean>
<!-- ÅäÖÃSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref="dataSource" p:mapperLocations="classpath*:com/smc/model/mappers/*.xml" />
<!-- MapperScannerÅäÖã¬×Ô¶¯ËÑË÷mapperÀïÃæµÄ¶ÔÏ󣬲¢×¢Èë -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="com.smc.dao">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<!-- Æô¶¯Spring×¢œâÊÂÎñ -->
<tx:annotation-driven />