cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<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>