liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
61
62
63
64
65
66
67
68
69
70
71
72
73
<?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 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
 
    <!-- 注解扫描包 -->
    <context:component-scan base-package="com.basic,framework" />
 
    <!-- 开启注解 -->
    <mvc:annotation-driven>
        <mvc:message-converters>
            <!-- @ResponseBody String 返回时,解决中文乱码 -->
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>text/plain;charset=UTF-8</value>
                        <value>text/html;charset=UTF-8</value>    
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    
    </mvc:annotation-driven>
 
    <!--
        配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,
        需要重新设置spring-mvc-3.0.xsd
    -->
    <mvc:resources location="/" mapping="/**"/>
    <mvc:resources mapping="/img/**" location="/img/" />
    <mvc:resources mapping="/js/**" location="/js/" />
    <mvc:resources mapping="/css/**" location="/css/" />
    <mvc:resources mapping="/html/**" location="/html/" />
    <mvc:resources location="/frame-jsp/" mapping="/frame-jsp/**"/>
    <mvc:resources location="/web-im-1.0.7.2/" mapping="/web-im-1.0.7.2/**" />
    <mvc:resources location="/test/" mapping="/test/**" />
    
    <!-- 定义跳转的文件的前后缀 ,视图模式配置-->
    <!-- 这里的配置是自动给后面action的方法return的字符串加上前缀和后缀,
        变成一个 可用的url地址 
    -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
    
    <!-- 文件上传 org.springframework.web.multipart.commons.CommonsMultipartResolver-->
    <bean id="multipartResolver" 
        class="framework.fileUpload.MyMultipartResolver">
        <property name="defaultEncoding" value="utf-8"></property>   
        <property name="maxUploadSize" value="10485760"></property>  <!-- 10M -->
        <property name="maxInMemorySize" value="1024"></property>  
   </bean>
   
   <!-- 拦截器 -->
   <mvc:interceptors>  
        <!-- 将request的parameter有选择的放在attribute里 -->  
        <bean class="framework.base.RequestParameterInterceptor"/> 
        <!-- 其他指定的请求
        <mvc:interceptor>  
            <mvc:mapping path="/**"/>  
            <bean class=""/>  
        </mvc:interceptor>
        --> 
    </mvc:interceptors>  
</beans>