Craig Walls wrote:That link that Anil gave is in regard to Spring's MultiActionController...which is quite similar to Struts' DispatcherServlet. That's one way of doing it, I suppose. But the new Spring @MVC model lets you do the same thing without implementing/extending any special controller. For example, consider this annotated controller:
(Note that I wrote this controller on-the-fly...I've not actually tried it...there may be some mistakes.)
This single controller responds to 3 kinds of requests:
- Requests for "/book/list" to display a list of all books
- GET requests for "/book/{bookId}" to display details for a given book ID
- DELETE requests for "/book/{bookId}" to delete a given book
Notice the RESTful-ness of this controller. It's not exactly the same as DispatchAction or MultiActionController...but I think it's something much better.
Hmm...this might workout . Thanks, though I am yet to explore that whether the Restful version has any side-effects.
It forces to stick to particular url format for one.But then it may not be a problem.
For the record, MultiActionController does not support the Command object. Not at least directly.
There is a Command controller but that does not support multi-operations.
This is the reason that MultiActioncontroller can not fill-in for DispatchAction without a workaround.