开发者

Need to verify the older way of defining handler mappings using mvc:annotation-driven?

开发者 https://www.devze.com 2023-01-08 20:43 出处:网络
In an app I\'m looking at I find this in the dispatcher xml: <mvc:annotation-driven /> Am I correct that this is the Spring 3 way of defining handler mappings (url routes). One of the control

In an app I'm looking at I find this in the dispatcher xml:

<mvc:annotation-driven />

Am I correct that this is the Spring 3 way of defining handler mappings (url routes). One of the controllers in the app looks like this:

@Controller
@RequestMapping("/order")
@SessionAttributes(OrderController.ORDER)
public class OrderController
{
 //...

I assume that the line

@RequestMapping("/order")

is the actual definition of the handler mapping for this url route.

Am I correct that the older way of defining this handler mapping would have been with one of:

  • BeanNameUrlHandlerMapping
  • SimpleUrlHandlerMapping
  • ControllerClassNameHandlerMapping开发者_Python百科
  • CommonsPathMapHandlerMapping


Yes. <mvc:annotation-driven /> is a convenience option for configuring Annotation-driven controllers. It configures special HandlerMappings and HandlerAdapters.

See the section in the Spring reference manual about <mvc:annotation-driven/> for a full list of what specifying this actually does.

As an alternative, you could always specify the DefaultAnnotationHandlerMapping, AnnotationMethodHandlerAdapter, etc. beans yourself manually.

0

精彩评论

暂无评论...
验证码 换一张
取 消