`
fancyboy2050
  • 浏览: 238716 次
  • 性别: Icon_minigender_1
  • 来自: 皇城根儿下
社区版块
存档分类
最新评论

spring mvc annotation-driven

阅读更多
使用spring mvc时,我们会在配置文件里添加<mvc:annotation-driven /><beans>
这个配置文件都加载了那些类呢?
1. Among others, registers: 
	* RequestMappingHandlerMapping 
	* RequestMappingHandlerAdapter 
	* ExceptionHandlerExceptionResolver 
in support of processing requests with annotated controller methods using annotations such as @RequestMapping , @ExceptionHandler, etc. 

2. Enables Spring 3 style type conversion through a ConversionService instance in addition to the JavaBeans PropertyEditors used for Data Binding. 

3. Enables support for formatting Number fields using the @NumberFormat annotation through the ConversionService. 

4. Enables support for formatting Date, Calendar, Long, and Joda Time fields using the @DateTimeFormat annotation, if Joda Time 1.3 or higher is present on the classpath. 

5. Enables support for validating @Controller inputs with @Valid, if a JSR-303 Provider is present on the classpath. 

6. Enables HttpMessageConverter support for @RequestBody method parameters and @ResponseBody method return values from @RequestMapping or @ExceptionHandler methods. 

This is the complete list of HttpMessageConverters set up by mvc:annotation-driven: 
* ByteArrayHttpMessageConverter converts byte arrays. 
* StringHttpMessageConverter converts strings. 
* ResourceHttpMessageConverter converts to/from org.springframework.core.io.Resource for all media types. 
* SourceHttpMessageConverter converts to/from a javax.xml.transform.Source. 
* FormHttpMessageConverter converts form data to/from a MultiValueMap<String, String>. 
* Jaxb2RootElementHttpMessageConverter converts Java objects to/from XML — added if JAXB2 is present on the classpath. This converter can read classes annotated with XmlRootElement and XmlType, and write classes annotated with withXmlRootElement, or subclasses thereof. 
* MappingJacksonHttpMessageConverter converts to/from JSON — added if Jackson is present on the classpath. 
* AtomFeedHttpMessageConverter converts Atom feeds — added if Rome is present on the classpath. 
* RssChannelHttpMessageConverter converts RSS feeds — added if Rome is present on the classpath. 

类似controller中ajax请求直接返回对象被组装成json格式,就是由于该配置文件注册了MappingJacksonHttpMessageConverter对象,当我们的工程引入了jackson相关的jar包,spring就可以自动将我们的返回对象封装成json对象输出给客户端。
分享到:
评论

相关推荐

    SpringMVC源码总结(二)mvc:mvc:annotation-driven背后的那些事

    NULL 博文链接:https://yihuawuye1.iteye.com/blog/2105063

    Spring MVC 教程 快速入门 深入分析

    Spring MVC 教程 快速入门 深入分析 目录 一、前言 二、spring mvc 核心类与接口 三、spring mvc 核心流程图 四、spring mvc DispatcherServlet说明 ...十九、 &lt;mvc:annotation-driven /&gt; 到底做了什么工作

    Spring MVC入门教程

    个人认为相当适合入门和知识巩固!! 一、前言 二、spring mvc 核心类与接口 ...十九、 &lt;mvc:annotation-driven /&gt; 到底做了什么工作 二十、 本文中springMVC.xml配置文件是核心,这里给一个下载地址

    SpringMVC框架架构介绍

    一、前言 二、spring mvc 核心类与接口 三、spring mvc 核心流程图 四、spring mvc ...十九、 &lt;mvc:annotation-driven /&gt; 到底做了什么工作 二十、 本文中springMVC.xml配置文件是核心,这里给一个下载地址

    Spring MVC internationalization annotation example

    Spring MVC internationalization annotation example 这个是annotation 方式的国际化 访问http://localhost:8080/login.htm

    Spring MVC Annotation验证的方法

    主要介绍了Spring MVC Annotation验证的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    Spring mvc demo

    利用Spring mvc annotation写成的demo

    Spring MVC + Hibernate +Annotation

    Spring MVC 整合Hibernate的一个小小的用例,适合初学Spring MVC 的学者。

    SpringMVC入门教程

    SpringMVC: 一、前言 二、spring mvc 核心类与接口 三、spring mvc 核心流程图 ...十九、 &lt;mvc:annotation-driven /&gt; 到底做了什么工作 二十、 本文中springMVC.xml配置文件是核心,这里给一个下载地址

    Spring MVC

    一个简单的spring mvc登录案例,采用的是annotation方式。

    Annotation Based Spring MVC Basics

    基于注解的Spring MVC,环境搭建,示例代码

    Spring mvc Aop+annotation实现系统日志记录功能实现的jar包

    Spring mvc Aop+annotation实现系统日志记录功能实现的jar包asm-3.3.jar ,aspectjrt.jar , aspectjweaver.jar , cglib-nodep-2.1_3.jar , spring-aop.jar

    SpringMVC-Annotation

    一个简单的例子,SPringMVC最常用的开发模式,通过注解的方式配置一个控制器和请求!

    Spring3 MVC 基础学习手册

    这里提供了Spring3 MVC中较为常见的使用方法,主要是利用Spring3官方文档建议使用的Annotation进行开发的一般步骤,包含了常见的集中Annotation的使用方法。

    license.txt

    &lt;mvc:annotation-driven&gt; &lt;/mvc:annotation-driven&gt; 中配置Json格式乱码。代码如下: &lt;!--json格式乱码处理--&gt; &lt;mvc:message-converters register-defaults="true"&gt; &lt;bean class="org.springframework....

    Getting.started.with.Spring.Framework.2nd.Edition1491011912.epub

    Chapter 6- Annotation-driven development with Spring Chapter 7 - Database interaction using Spring Chapter 8 - Messaging, emailing, asynchronous method execution, and caching using Spring Chapter 9 - ...

    Portlets in action

    Annotation-driven development with Spring Integrating portlets with databases PART 3 ADVANCED PORTLET DEVELOPMENT Personalizing portlets Communicating with other portlets Ajaxing portlets Reusable ...

    spring_MVC源码

    51. &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt; 52. &lt;tx:annotation-driven mode="aspectj"/&gt; 53. 54. &lt;aop:aspectj-autoproxy/&gt; 55.&lt;/beans&gt; hibernate.properties数据库连接...

    iLink:拉丁云代码测试Spring MVC

    spring-mvc.xml 配置自动扫描的包、配置视图解析器 如何把 handler方法返回值解析为实际的物理视图、配置静态资源映射静态资源交给默认的Servlet、配置 mvc:annotation-driven标签开启注解(4)@RestController =@...

    将dwr集成到spring mvc(dwr的配置是基于xml)

    将dwr集成到spring mvc(dwr的配置是基于xml)

Global site tag (gtag.js) - Google Analytics