Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dispatch Action Equivalent in Spring?

 
tapeshwar sharma
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Craig,
I used Struts 1.2 heavily before switching over to Spring MVC since Spring 2.0.
However, I have not been able to find an equivalent yet for the DispatchAction in Struts 1.2.
Actually, not even in Struts 2.0 for that matter.
I find DispatchAction really helpful and efficient for CRUD like operations.
Does Spring 3.0 provide some Controller like that or is there an easy work around for that ?
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tapeshwar sharma wrote:Hi Craig,
I used Struts 1.2 heavily before switching over to Spring MVC since Spring 2.0.
However, I have not been able to find an equivalent yet for the DispatchAction in Struts 1.2.
Actually, not even in Struts 2.0 for that matter.
I find DispatchAction really helpful and efficient for CRUD like operations.
Does Spring 3.0 provide some Controller like that or is there an easy work around for that ?


Google search yielded this link although it is for Spring 2.0
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 2 provides dynamic method invocation.
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
tapeshwar sharma
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic