Generally we have mapping in xml file for dispatcher servlet to decide which controller to use as per URL mapping but if we have to take decision on basis of request parameters then MultiActionController can be used.

Spring offers a multi-action controller with which multiple actions can be aggregated into one controller, grouping functionality together. The multi-action controller is capable of mapping requests to method names and then invoking the right method name. Using the multi-action controller is especially handy when you have a lot of common functionality in one controller, but want to have multiple entry points to the controller.


 import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class DispatchController extends MultiActionController {

  public ModelAndView actionName(HttpServletRequest request, HttpServletResponse response) 
    throws Exception {

    String msg = "message is Here";
    ModelAndView mav = new ModelAndView("myview");
    mav.addObject("message", msg);
    return mav;