美文网首页
<mvc:annotation-driven />

<mvc:annotation-driven />

作者: lovePython | 来源:发表于2015-08-19 14:21 被阅读196次

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

相关文章

网友评论

      本文标题:<mvc:annotation-driven />

      本文链接:https://www.haomeiwen.com/subject/wohgqttx.html