Social Icons

Spring 2.0 MVC - MultiActionController

Let's check out a simple example to use Spring 2.0 MultiActionController

Notably, Spring provides a handful number of controllers each of which has their advantages of implementation. Personally, I prefer and use MultiActionController more often, mainly due to the way it actually works!

What you need ?

Eclipse - Download from
Spring 2.0 Libraries - Download from
JSTL 1.2.1 Libraries - Download from
Commons Logging Libraries - Download from
Log4j Libraries - Download from

Jars to be present in WEB-INF/lib folder

Now that we have all required libraries ready, let's look at what changes / additions you need to do to a empty web app to make it Spring enabled.


Configure the dispatcher servlet in web.xml and servlet-mapping to intercept the requests.


The SimpleUrlHandlerMapping maps the URLs to each Controller beans.
The ParameterMethodNameResolver defines that method name to be executed must be reolved from the URL parameter, while the defaultMethodName is set to 'loadPage'

This is the Controller class. Note that loadPage method is automatically executed when request comes to /
If the request contains any param like / then doLogout will be executed. ModelAndView object is returned, which is mapped by the 'viewresolver' configuration in DemoApp-servlet.xml


Note the form action here.


Note the href tag for logout here.

 Download Eclipse project


Post a Comment