<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 />在Spring MVC中的作用,它用于自动注册DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter,支持@Controllers处理请求。此注解还提供数据绑定、日期时间格式化、@Valid验证以及XML和JSON的读写支持。在处理Ajax请求和编写JUnit单元测试时,该注解尤为重要。

1327

被折叠的 条评论
为什么被折叠?



