zoukankan      html  css  js  c++  java
  • springMVC之servlet-config.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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-4.0.xsd
                http://www.springframework.org/schema/aop 
                http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
                http://www.springframework.org/schema/tx 
                http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
                http://www.springframework.org/schema/mvc 
                http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
                http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-4.0.xsd">
        
        <!--使Spring支持自动检测组件,如注解的Controller -->
        <context:component-scan base-package="com.parry.test.*" />
        
        <!--*************** 支持aop **************** -->
        <aop:aspectj-autoproxy proxy-target-class="true" />
         
        <mvc:resources location="/img/" mapping="/img/**" />
        <!-- /js/文件夹下的文件不需要拦截 -->
        <mvc:resources location="/js/" mapping="/js/**" />
        <!-- /css/文件夹下的文件不需要拦截 -->
        <mvc:resources location="/css/" mapping="/css/**" />
        
        <!-- 视图解析器 -->
        <bean id="viewResolver"
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/"></property>
            <property name="suffix" value=".html"></property>
        </bean>
        
        <!-- 支持用注解的方式验证参数格式正确性 -->  
        <mvc:annotation-driven validator="validator" conversion-service="conversion-service" />
        
        <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <!-- <property name="providerClass"  value="org.hibernate.validator.HibernateValidator"/> -->
        <!--不设置则默认为classpath下的 ValidationMessages.properties
        <property name="validationMessageSource" ref="validatemessageSource"/> -->
        </bean>
        <bean id="conversion-service" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
        <bean id="validatemessageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">  
            <property name="basename" value="classpath:validatemessages"/>  
            <property name="fileEncodings" value="utf-8"/>  
            <property name="cacheSeconds" value="120"/>
        </bean>
        <!-- 拦截器 -->
        <mvc:interceptors>
            <mvc:interceptor>
                <mvc:mapping path="/api/*"/>
                <bean class="com.parry.test.interceptor.SignatureCheckInterceptor"></bean>
            </mvc:interceptor>
            <mvc:interceptor>
                <mvc:mapping path="/web/*"/>
                <bean class="com.parry.test.interceptor.AccessCheckInterceptor"></bean>
            </mvc:interceptor>
        </mvc:interceptors>
        <mvc:annotation-driven>
        </mvc:annotation-driven>
        <!-- 文件上传配置 -->
        <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">  
             <!-- 设置上传文件的最大尺寸为1MB -->
             <property name="maxUploadSize">  
                <value>1048576</value>  
            </property>
            <property name="defaultEncoding">
                <value>UTF-8</value>
            </property> 
        </bean>
    </beans>
  • 相关阅读:
    CodeForces 543d Road Improvement
    UVA Foreign Exchange
    ZOJ 1825 Compound Words
    UVA 10125 Sumsets
    CodeForces
    32位linux(centos)下mongoDB的安装
    关于PHP 采集类
    关于微信支付零时工代码的修正方法
    微信公众号申请,微信支付全攻略 2
    简介CentOS与 Ubuntu的不同
  • 原文地址:https://www.cnblogs.com/parryyang/p/5783440.html
Copyright © 2011-2022 走看看