如果不配置其他参数,大致相当于以下的配置文件(参考自org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser) 
<!-- 配置路径扩展名映射的媒体类型 -->
<bean name="pathExtensionContentNegotiationStrategy"
class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
<constructor-arg>
<props>
<!-- if romePresent -->
<prop key="atom">application/atom+xml</prop>
<prop key="rss">application/rss+xml</prop>
<!-- endif -->
<!-- if jackson2Present || jacksonPresent -->
<prop key="json">application/json</prop>
<!-- endif -->
<!-- if jaxb2Present -->
<prop key="xml">application/xml</prop>
<!-- endif -->
</props>
</constructor-arg>
</bean> <!-- 配置映射媒体类型的策略 -->
<bean name="mvcContentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManager">
<constructor-arg>
<list>
<ref bean="pathExtensionContentNegotiationStrategy" />
</list>
</constructor-arg>
</bean> <!-- 配置方法级别的@RequestMapping处理器 -->
<bean name="requestMappingHandlerMapping"
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="order" value="0" />
<property name="contentNegotiationManager" ref="mvcContentNegotiationManager" />
</bean> <!-- 配置数据转换服务,默认使用格式化数据转换服务,可以对日期和数字进行格式化 -->
<bean name="conversionService"
class="org.springframework.format.support.DefaultFormattingConversionService">
<constructor-arg index="0">
<null></null>
</constructor-arg>
<constructor-arg index="1">
<value>true</value>
</constructor-arg>
</bean> <bean name="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"></bean> <!-- 配置数据绑定,通过转换服务实现绑定,如果包含jsr303实现还将进行校验 -->
<bean name="webBindingInitializer"
class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService" ref="conversionService" />
<!-- if jsr303Present -->
<property name="validator" ref="validator" />
<!-- endif -->
</bean> <bean name="byteArrayHttpMessageConverter"
class="org.springframework.http.converter.ByteArrayHttpMessageConverter"></bean>
<bean name="stringHttpMessageConverter"
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="writeAcceptCharset" value="false" />
</bean>
<bean name="resourceHttpMessageConverter"
class="org.springframework.http.converter.ResourceHttpMessageConverter"></bean>
<bean name="sourceHttpMessageConverter"
class="org.springframework.http.converter.xml.SourceHttpMessageConverter"></bean>
<bean name="allEncompassingFormHttpMessageConverter"
class="org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter"></bean>
<bean name="atomFeedHttpMessageConverter"
class="org.springframework.http.converter.feed.AtomFeedHttpMessageConverter"></bean>
<bean name="rssChannelHttpMessageConverter"
class="org.springframework.http.converter.feed.RssChannelHttpMessageConverter"></bean>
<bean name="jaxb2RootElementHttpMessageConverter"
class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"></bean>
<bean name="mappingJackson2HttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean>
<bean name="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean> <!-- 配置@RequestBody,@ResponseBody注解可用的转换器 -->
<util:list id="messageConverters"
list-class="org.springframework.beans.factory.support.ManagedList.ManagedList">
<ref bean="byteArrayHttpMessageConverter" />
<ref bean="stringHttpMessageConverter" />
<ref bean="resourceHttpMessageConverter" />
<ref bean="sourceHttpMessageConverter" />
<ref bean="allEncompassingFormHttpMessageConverter" />
<!-- if romePresent -->
<ref bean="atomFeedHttpMessageConverter" />
<ref bean="rssChannelHttpMessageConverter" />
<!-- endif -->
<!-- if jaxb2Present -->
<ref bean="jaxb2RootElementHttpMessageConverter" />
<!-- endif -->
<!-- if jackson2Present -->
<ref bean="mappingJackson2HttpMessageConverter" />
<!-- endif -->
<!-- if jacksonPresent -->
<ref bean="mappingJacksonHttpMessageConverter" />
<!-- endif -->
</util:list> <!-- 将任意类型的Controller适配为Handler -->
<bean name="requestMappingHandlerAdapter"
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="contentNegotiationManager" ref="mvcContentNegotiationManager" />
<property name="webBindingInitializer" ref="webBindingInitializer" />
<property name="messageConverters" ref="messageConverters" />
</bean> <!-- 这个拦截器暴露转换器服务让spring:bind和spring:eval标签可用 -->
<bean name="csInterceptor"
class="org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor">
<constructor-arg index="0">
<ref bean="conversionService" />
</constructor-arg>
</bean> <!-- 现在所有拦截器都必须设定响应的路径映射 -->
<bean name="mappedCsInterceptor"
class="org.springframework.web.servlet.handler.MappedInterceptor">
<constructor-arg index="0">
<null></null>
</constructor-arg>
<constructor-arg index="1">
<ref bean="csInterceptor" />
</constructor-arg>
</bean> <!-- 使用@ExceptionHandler注解的方法来处理Exception,优先级为0(最高) -->
<bean name="exceptionHandlerExceptionResolver"
class="org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver">
<property name="contentNegotiationManager" ref="mvcContentNegotiationManager" />
<property name="messageConverters" ref="messageConverters" />
<property name="order" value="0" />
</bean> <!-- 如果抛出的Exception类带有@ResponseStatus注解,响应返回该注解的Http状态码,优先级为1 -->
<bean name="responseStatusExceptionResolver"
class="org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver">
<property name="order" value="1" />
</bean> <!-- SpringMvc内部异常处理 -->
<bean name="defaultExceptionResolver"
class="org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver">
<property name="order" value="2" />
</bean>

spring MVC <mvc:annotation-driven>的更多相关文章

  1. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework中的spring web MVC模块

    spring framework中的spring web MVC模块 1.概述 spring web mvc是spring框架中的一个模块 spring web mvc实现了web的MVC架构模式,可 ...

  2. spring 3 mvc hello world + mavern +jetty

    Spring 3 MVC hello world example By mkyong | August 2, 2011 | Updated : June 15, 2015 In this tutori ...

  3. Spring Boot——2分钟构建spring web mvc REST风格HelloWorld

    之前有一篇<5分钟构建spring web mvc REST风格HelloWorld>介绍了普通方式开发spring web mvc web service.接下来看看使用spring b ...

  4. Gradle – Spring 4 MVC Hello World Example

    In this tutorial, we will show you a Gradle + Spring 4 MVC, Hello World Example (JSP view), XML conf ...

  5. Spring 3 MVC: Themes In Spring-Tutorial With Example---reference

    Welcome to Part 6 of Spring 3.0 MVC Series. In previous article we saw how to add Internationalizati ...

  6. [转]Spring Boot——2分钟构建spring web mvc REST风格HelloWorld

    Spring Boot——2分钟构建spring web mvc REST风格HelloWorld http://projects.spring.io/spring-boot/ http://spri ...

  7. Spring 4 MVC+Hibernate 4+MySQL+Maven使用注解集成实例

    Spring 4 MVC+Hibernate 4+MySQL+Maven使用注解集成实例 转自:通过注解的方式集成Spring 4 MVC+Hibernate 4+MySQL+Maven,开发项目样例 ...

  8. Spring Web MVC(三)之注解

    [toc] spring web mvc 基于注解的优化 我写的注解是按照spring web的部件分类写的,这样的话比较方便查看,大家感觉有用的话可以分享个别人,希望对对更多的人有帮助.毕竟零基础开 ...

  9. Spring 4 MVC example with Maven

    In this tutorial, we show you a Spring 4 MVC example, using Maven build tool. Technologies used : Sp ...

  10. Spring 4 MVC example with Maven - [Source Code Download]

    In this tutorial, we show you a Spring 4 MVC example, using Maven build tool. Technologies used : Sp ...

随机推荐

  1. 专题:OpenSSL

    一.常用操作 对称加密: openssl enc -e -aes256 -base64 -in goal.file -out result.file 加密,-base64 指使用 base64 編码 ...

  2. (数据科学学习手札58)在R中处理有缺失值数据的高级方法

    一.简介 在实际工作中,遇到数据中带有缺失值是非常常见的现象,简单粗暴的做法如直接删除包含缺失值的记录.删除缺失值比例过大的变量.用0填充缺失值等,但这些做法会很大程度上影响原始数据的分布或者浪费来之 ...

  3. Elasticsearch索引别名使用

    背景 项目中使用的老的索引,由于数据冗余,会想影响性能.因此需要重新建立索引,但是这样必然需要更新服务中的索引名称,然后重新启动服务,可能会对服务的使用者产生一定的影响.因此,调研了Elasticse ...

  4. 初探Javascript魅力(1)

    转自:CSDN--http://blog.csdn.net/cherry_vicent/article/details/42120149 1.javascript是什么   根据用户的一些操作,然后来 ...

  5. No package docker-io available

    新手centos6.8安装docker时从遇到No package docker-io available开始的各种不小心的坑... 新安装了CentOS6.8,准备安装docker,执行命令 yum ...

  6. Pregel的应用实例——单源最短路径

  7. nginx打包成rpm

    [root@localhost ~ ]#yum -y install lrzsz pcre pcre-devel zlib zlib-devel vim nrt-tools psmisc gcc gc ...

  8. 用python 编写redis 暴力破解密码的程序

    本文摘自http://blog.knownsec.com/2015/11/analysis-of-redis-unauthorized-of-expolit/ import redisimport l ...

  9. python+selenium遍历某一个标签中的内容

    一.python+selenium遍历某一个标签中的内容 举个例子:我要获取列表标签<li></li>的内容 根据python+selenium定位到列表整体,使用for循环获 ...

  10. python之next和send用法详解

    如果send不携带参数,那么send(None) 和next()的作用的相同的,如: def a(): print('aaa') p = ' #print(p) print('bbb') r = a( ...