Sorry for the slow response to this one.
Splitting the handler methods for a single portlet mode across multiple classes does work, but the configuration is still a bit brittle. The current issue has to do with the order in which the Controller classes are mapped into the DefaultAnnotationHandlerMapping. The key is that the class that contains the "default" handler method (i.e. the one that doesn't specify any request parameters) needs to get mapped last.
Here is an example from the sample code I am working on right now.
BooksController class:
Code:
@Controller
@RequestMapping("VIEW")
@SessionAttributes("book")
public class BooksController {
...
@RequestMapping
public String listBooks(Model model) {
...
}
@RequestMapping(params="action=viewBook")
public String viewBook(@RequestParam("book") Integer id, Model model) {
...
}
...
}
BooksAddController class:
Code:
@Controller
@RequestMapping("VIEW")
@SessionAttributes("book")
public class BooksAddController {
...
@RequestMapping(params="action=addBook")
public String showAddBookForm(Model model) {
...
}
...
}
So, these will only get mapped correctly if the BooksAddController appears first and the BooksController appears second in the bean declarations. Like this:
Code:
<bean id="booksAddController" class="sample.portlet.BooksAddController"/>
<bean id="booksController" class="sample.portlet.BooksController"/>
<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
You can verify the mapping order if you enable debug-level in your logging. You should see something like this:
Code:
2008-05-21 09:18:42,916 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksAddController@e0ada6]>
2008-05-21 09:18:42,917 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksAddController@e0ada6]>
2008-05-21 09:18:42,917 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
2008-05-21 09:18:42,917 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
2008-05-21 09:18:42,918 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
2008-05-21 09:18:42,918 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
2008-05-21 09:18:42,918 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
2008-05-21 09:18:42,918 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
2008-05-21 09:18:42,918 DEBUG [org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping] - <Mapped key [view] onto handler [sample.portlet.BooksController@7bacb]>
I'll work with Juergen to see if we can make the DefaultAnnotationHandlerMapping even more flexible in this area, so that the ordering is not so critical, but this is how it works for now.
Hope that helps!