The MultiActionControllerhas the following capabilities:
- flexible action method mapping, defaulting to URL to method name mapping
- command bean binding
- support for one or more Validators
- per-action “last modified” timestamp control
•exception handling
■CautionEven though this Controllersupports Validators and command bean binding, it does not
define a form handling work flow.
On initialization, this class searches all of its methods for any that conform to the request
handler signature. Any method that will handle a request must conform to the following
features:
•returns ModelAndView
- accepts an HttpServletRequestas a first parameter
- accepts an HttpServletResponseas a second parameter
- optionally, accept either an HttpSessionor an Object(to be treated as the command
bean) as a third parameter
■NoteThe name of the method does not matter when locating potential request handling methods.
Listing 6-55 contains a simple MultiActionControllerwith three different but valid
request handling methods.
Listing 6-55.Example Request Handling Method Signature
public class MyMultiController extends MultiActionController {
public ModelAndView doStuff(HttpServletRequest req,
HttpServletResponse res) { ... }
public ModelAndView doOtherStuff(HttpServletRequest req,
HttpServletResponse res, HttpSession session) { ... }
public ModelAndView doStuff(HttpServletRequest req,
HttpServletResponse res, CommandBean command) { ... }
}
CHAPTER 6 ■THE CONTROLLER MENAGERIE 169