<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-context.xml</param-value>
</context-param>
spring总配置文件
<?xml version="1.0" encoding="UTF-8"?>
<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:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
default-autowire="byName">
<context:component-scan base-package="com.jd.im.**"/>
<mvc:annotation-driven/>
<bean>
<property>
<list>
<value>classpath:im-king.properties</value>
<value>classpath:important.properties</value>
<value>classpath:jss_config.properties</value>
</list>
</property>
</bean>
<import resource="spring/spring-config-mvc.xml"></import>
<import resource="spring/spring-config-datasource.xml"/>
</beans>
总配置文件里集成了spring mvc配置文件和ibatis数据源的配置文件。
spring mvc 配置
<?xml version="1.0" encoding="UTF-8"?>
<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
">
<context:component-scan base-package="com.**.dd.mall.web.controller" />
<mvc:annotation-driven />
<bean></bean>
<!-- Json返回 乱码处理 -->
<bean>
<property>
<list>
<bean>
<property ref="dateObjectMapper"></property>
</bean>
<bean />
<bean>
<property>
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
<bean />
<bean />
<bean />
<bean />
</list>
</property>
</bean>
<mvc:resources mapping="/dist/**" location="/dist/" cache-period="3600" />
<mvc:resources mapping="/js/**" location="/js/" cache-period="3600" />
<mvc:resources mapping="/css/**" location="/css/" cache-period="3600" />
<!--<mvc:resources mapping="/fonts/**" location="/fonts/" cache-period="3600" /> -->
<mvc:resources mapping="/config.json" location="/" cache-period="3600" />
<mvc:resources mapping="/image/**" location="/image/" cache-period="3600" />
<!-- 对转向页面的路径解析。prefix:前缀, suffix:后缀 -->
<bean>
<property value="true"></property>
<property value=".vm"></property>
<property value=""></property>
<property value="text/html;charset=utf-8"></property>
<property value="true"></property>
<property value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"></property>
</bean>
<bean>
<property value="/WEB-INF/vm/"></property>
<property value="classpath:velocity.properties"></property>
</bean>
<bean>
<property value="10485760" />
<property value="utf-8"></property>
</bean>