Spring support for @Controller given by vs

后端 未结 3 832
你的背包
你的背包 2020-12-13 22:16

I\'ve been researching what additional capabilities we have when using the mvc:annotation-driven tag and I\'m having a difficult time digesting the results, especially in re

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 22:57

    The context:component-scan element lists a package that Spring should scan for @Controller annotations (in the base-package attribute).

    the mvc:annotation-driven has no such attribute. This is a convenience element that installs a lot of default MVC elements into the application context. These elements are listed in section 16.14.1 of the Spring framework reference. This element does not appear to scan for @Controller annotations.

    Contrary to popular belief, there is no dependancy between these elements. An @Controller without mvc:annotation-driven will function without an issue and handle HTTP requests just fine, as long as you have included context:component-scan with an appropriate base-package attribute.

提交回复
热议问题