<mvc:annotation-driven /> 作用
2017-09-17 21:10
375 查看
<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。
and so on.
etc), even though support for those is the default behaviour.
My advice is to always declare
you want JSON support via Jackson.
并提供了:数据绑定支持,@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.
相关文章推荐
- <mvc:annotation-driven/>注解的作用
- SpringMVC-<mvc:annotation-driven>的作用
- Spring中<mvc:annotation-driven />的作用
- spring中配置<aop:aspectj-autoproxy/>与<mvc:annotation-driven/>作用以及国际化配置
- <mvc:annotation-driven/>作用
- 【springMVC】<mvc:annotation-driven />标签的使用、作用?
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- Spring MVC学习-----------<mvc:annotation-driven /> 到底做了什么工作
- <mvc:annotation-driven />注解意义
- SpringMVC—<mvc:annotation-driven/>标签
- SpringMVC系列(十)<mvc:default-servlet-handler/>(处理静态资源)和<mvc:annotation-driven />
- 【Spring MVC】<mvc:annotation-driven/>详解
- spring <context:component-scan />及<mvc:annotation-driven />使用说明
- <mvc:annotation-driven />注解意义
- <mvc:annotation-driven/>
- Spring MVC 解读——<mvc:annotation-driven/>(剖析的比较的详细)
- 掀开<mvc:annotation-driven/>的面纱
- <context:annotation-config/>,<context:component-scan/>,<mvc:annotation-driven/>区分
- SpringMVC异常_01_约束_<mvc:annotation-driven />报错
- <mvc:annotation-driven />