<beans xmlns="http://www.springframework.org/schema/beans"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
xmlns:context="http://www.springframework.org/schema/context"
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
http://www.springframework.org/schema/mvc
|
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
|
|
<!-- 开启注解 -->
|
<mvc:annotation-driven/>
|
<!-- 注解扫描包 -->
|
<context:component-scan base-package="cn.ksource">
|
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
|
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
|
</context:component-scan>
|
|
<!-- 静态资源访问 -->
|
<mvc:resources location="/static/" mapping="/static/**"/>
|
|
<!-- 拦截器 -->
|
<mvc:interceptors>
|
<!-- 多个拦截器,顺序执行 -->
|
<mvc:interceptor>
|
<!-- 如果不配置或/**,将拦截所有的Controller -->
|
<mvc:mapping path="/**"/>
|
<!-- 在Freemarker界面展示之前做一些通用处理 -->
|
<bean class="cn.ksource.core.web.FreeMarkerViewInterceptor"></bean>
|
</mvc:interceptor>
|
</mvc:interceptors>
|
|
|
<!-- 针对freemarker的视图配置 -->
|
<bean id="viewResolver"
|
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
|
<property name="cache" value="true"/>
|
<property name="prefix" value=""/>
|
<property name="suffix" value=".html"/>
|
<property name="contentType" value="text/html;charset=UTF-8"></property>
|
<property name="requestContextAttribute" value="request"/>
|
<property name="exposeSpringMacroHelpers" value="true"/>
|
<property name="exposeRequestAttributes" value="true"/>
|
<property name="allowSessionOverride" value="true"/>
|
<property name="exposeSessionAttributes" value="true"/>
|
</bean>
|
|
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
<property name="defaultEncoding" value="utf-8"/>
|
<property name="maxUploadSize" value="10485760000"/>
|
<property name="maxInMemorySize" value="40960"/>
|
</bean>
|
|
<!--异常处理 -->
|
<bean id="exceptionResolver" class="cn.ksource.web.exception.ExceptionHandler">
|
<property name="defaultError" value="business/error/showError"/>
|
</bean>
|
|
</beans>
|