zoukankan      html  css  js  c++  java
  • 注解意义

    <mvc:annotation-driven /> 是一种简写形式,完全可以手动配置替代这种简写形式,简写形式可以让初学都快速应用默认配置方案。<mvc:annotation-driven /> 会自动注册DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,是spring MVC为@Controllers分发请求所必须的。
    并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。
    后面,我们处理响应ajax请求时,就使用到了对json的支持。
    后面,对action写JUnit单元测试时,要从spring IOC容器中取DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,来完成测试,取的时候要知道是<mvc:annotation-driven />这一句注册的这两个bean。

    <context:annotation-config> declares support for general annotations such as @Required, @Autowired, @PostConstruct, and so on.

    <mvc:annotation-driven /> is actually rather pointless. It declares explicit support for annotation-driven MVC controllers (i.e.@RequestMapping, @Controller, etc), even though support for those is the default behaviour.

    My advice is to always declare <context:annotation-config>, but don't bother with <mvc:annotation-driven /> unless you want JSON support via Jackson.

    当我们需要controller返回一个map的json对象时,可以设定<mvc:annotation-driven />,

    同时设定<mvc:message-converters> 标签,设定字符集和json处理类。


    转载地址:http://kingliu.iteye.com/blog/1972973

  • 相关阅读:
    vi 整行 多行 复制与粘贴
    FPGA设计—UVM验证篇 Hello world
    武汉市最大的二手车市场
    vim 使用技巧
    CentOS 7下的软件安装方法及策略
    搜索插件:ack.vim
    Vim插件管理
    【一】 sched.h
    Android USB驱动源码分析(-)
    在Python中反向遍历序列(列表、字符串、元组等)的五种方式
  • 原文地址:https://www.cnblogs.com/archermeng/p/7537142.html
Copyright © 2011-2022 走看看