views:

24

answers:

1

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
  • CommonsPathMapHandlerMapping
+1  A: 

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.

matt b
Thanks for the docs link.
pnut butter