vs会支持java吗_java – 由vs给出的@Controller的Spring支持

我一直在研究使用mvc:annotation-driven标签时我们有哪些额外的功能,我很难消化结果,特别是在@Controller注释方面.我知道这与this question非常相似,但请听我说.

The basic purpose of the @Controller annotation is to act as a stereotype for the annotated class, indicating its role. The dispatcher will scan such annotated classes for mapped methods, detecting @RequestMapping annotations (see the next section).

然后,文档继续显示上下文:component-scan标记提供此支持.所以这一切都很好,但后来我看着mvc:annotation-driven给了我们,前面提到的stackoverflow question提供了以下答案

mvc:annotation-driven declares explicit support for annotation-driven MVC controllers (i.e. @RequestMapping, @Controller, although support for those is the default behaviour), as well as adding support for declrative validation via @Valid and message body marshalling with @RequestBody/ResponseBody.

这对我来说似乎有点多余.也许我得不到这种明确的支持.再次,回顾官方的Spring documentation,我们得到以下内容

[mvc:annotation-driven] registers the DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter beans that are required for Spring MVC to dispatch requests to @Controllers.

这听起来与我从文档中提供的最后一个例子非常相似.如果任何人都可以提供一些关于我们如何使用@Controller注释只使用上下文:component-scan标签,一些限制是什么,那么我们在添加mvc:annotation-driven时获得的附加功能的示例标签,我认为这将非常有帮助.在此先感谢任何支持.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值