views:

33

answers:

4

I'm trying to learn Spring MVC from Spring In Action 2nd Edition (Covers Spring 2.0).

My IDE tells me that AbstractCommandController has been deprecated. Has it been replaced? What is the recommended way of handling cases for which one would have extended AbstractCommandController?

+2  A: 

Like the javadoc of AbstractCommandController says:

@deprecated as of Spring 3.0, in favor of annotated controllers

So, look at the spring reference documentation for annotated controllers.

tangens
+3  A: 

As of Spring 3.0, the entire Controller hierarchy has been deprecated and replaced by the annotation-style of controllers. This makes things considerably simpler, you no longer have to worry about which of the various base classes to extend.

In fact, you won't even find mention of the old hierarchy in the Spring reference manual any more, just the new annotation-style.

Annotated controllers perform the same functionality as AbstractCommandController by simple auto-binding of method parameters, e.g.

@Controller
public class MyController {

    @RequestMapping
    public String handleMe(Command command) {
       ...
    }
}
skaffman
+1  A: 

Your book covers Spring 2.0 which relies on subclasses of the AbstractCommandController. In Spring 2.5 the equivalent of an AbstractCommandController is the AbstractController. In Spring 3.0 (as others have pointed out) the equivalent is a properly annotated @Controler class.

CitizenForAnAwesomeTomorrow
+1  A: 

Here is a simple example I wrote about using annotation-based Spring MVC, which might help get you started.

It is part of this series.

James Earl Douglas