<?xml version="1.0" encoding="UTF-8"?>
<!-- 最外层beans标签 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 启用注解 -->
<context:annotation-config/>
<!-- 自动注解 @Controller类,使得能够分发以及获得json转换等一系列支持-->
<mvc:annotation-driven />
<!-- 资源文件配置,静态访问,不被DispatcherServlet所分发 -->
<mvc:resources mapping="/citi/img/**" location="/img/"/>
<!-- 扫描的包路径,所有需要自动装配的包都需要扫描 -->
<context:component-scan base-package="citi.*"/>
<!-- 引入资源文件,在引入的地方可以使用占位符使用value值 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 启动web容器服务器默认服务器,将静态资源请求交给它处理(需要在web.xml配置) -->
<mvc:default-servlet-handler/>
<!-- 拦截器配置-->
<mvc:interceptors>
<mvc:interceptor>
<!-- 被拦截的路径 -->
<mvc:mapping path="/**"/>
<!-- 不拦截的路径,例外的路径 -->
<mvc:exclude-mapping path="/login/**"/>
<!-- 类路径 -->
<bean class="citi.interceptor.AuthIeterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<!-- 绑定数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- mybatis会话工厂 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
</bean>
<!-- 自动扫描mybatis映射文件和接口的包 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="citi.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<!-- gson注入 -->
<bean id="gson" class="com.google.gson.Gson">
</bean>
<!-- ModelAndView默认后缀名以及路径 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>