zoukankan      html  css  js  c++  java
  • spring-servlet.xml

    <?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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd  
            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.2.xsd">
        
        <!-- 开启spring mvc 注释 -->
        <!-- <mvc:annotation-driven></mvc:annotation-driven> -->
        
        <!-- 开启自定义注释 -->
        <mvc:annotation-driven validator="validator" />
        
        <bean id="messageSource"
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basenames">
                <list>
                    <value>classpath:i18n/zn</value>
                </list>
            </property>
            <property name="useCodeAsDefaultMessage" value="true" />
        </bean>
        
        <bean id="validator"
            class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
            <property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
            <!-- 这里配置将使用上面国际化配置的messageSource -->
            <property name="validationMessageSource" ref="messageSource" />
        </bean>
        
        <!--定义spring mvc 扫描包 -->
        <context:component-scan base-package="com.csit.springmvc.controllers"></context:component-scan>
        
        <!-- ViewResolver 配置 页面信息 -->
        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/views/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>
        
        <!-- 支持上传文件 -->
        <bean id="multipartResolver"
            class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
    
        <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
        <bean id="mappingJacksonHttpMessageConverter"
            class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="supportedMediaTypes">
                <list>
                    <value>text/html;charset=UTF-8</value>
                </list>
            </property>
        </bean>
    
        <bean
            class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
            <property name="messageConverters">
                <list>
                    <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
                </list>
            </property>
        </bean>
        
        <!-- 定义拦截器 -->
        <mvc:interceptors>
            <mvc:interceptor>
                <mvc:mapping path="/router/**" />
                <!-- 定义在mvc:interceptor下面的表示是对特定的请求才进行拦截的 -->
                <bean class="com.csit.springmvc.interceptor.SpringMVCInterceptor" />
            </mvc:interceptor>
        </mvc:interceptors>

      <!-- 前后缀映射 -->
      <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB_INF/view"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>

       <!-- 处理静态资源 -->
        <mvc:default-servlet-handler />
    </beans>
  • 相关阅读:
    练手
    课余时间娱乐下
    2017-2-19,作业
    JavaScript(下)
    JavaScript(上)
    Day15:网络编程-HTTP
    小知识:静态导入
    多线程知识点:锁
    多线程知识点:同步
    Day16:反射技术
  • 原文地址:https://www.cnblogs.com/ScvQ/p/6929368.html
Copyright © 2011-2022 走看看