<mvc:annotation-driven />

2015-08-19  本文已影响196人  lovePython

<mvc:annotation-driven /> 会自动注册DefaultAnnotationHandlerMappingAnnotationMethodHandlerAdapter两个bean,是spring MVC为@Controllers分发请求所必须的。并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。

<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.

上一篇 下一篇

猜你喜欢

热点阅读