Spring-Spring MVC4 Comments

In Spring MVC application, MultiActionController is used to group related actions into a single controller, the method handler have to follow below signature :

  • MultiActionController

See a MultiActionController example.

With ControllerClassNameHandlerMapping configured.

  • Mapping Examples

Now, the reuqested URL will map to the method name in the following patterns :

  1. CustomerController –> /customer/*
  2. /customer/add.htm –> add()
  3. /customer/delete.htm –> delete()
  4. /customer/update.htm –> update()
  5. /customer/list.htm –> list()
  • InternalPathMethodNameResolver

The InternalPathMethodNameResolver is the default MultiActionController implementation to map URL to method name. But, you are still allow to add prefix or suffix to the method name :

Now, the URL will map to the method name in the following pattern :

  1. CustomerController –> /customer/*
  2. /customer/add.htm –> testaddCustomer()
  3. /customer/delete.htm –> testdeleteCustomer()
  4. /customer/update.htm –> testupdateCustomer()
  5. /customer/list.htm –> testlistCustomer()
With annotation, the MultiActionController is more easy to configure, visit this MultiActionController annotation example for detail.

4 Comments on this article

Add a comment