Transition Paths from Struts to Spring MVC
There are three approaches to migrating Struts applications to Spring MVC. Some architects will gradually migrate the applications; others will choose to completely abandon the Struts framework and perform a complete rewrite. The approaches are outlined below and ordered according to the migration’s completeness.
1. Spring Enabling of Struts Components
For those who want to migrate slowly, the firstand completely painlessstep is to enable Struts Actions as Spring Beans. This is a simple process, and the Spring documentation details it well. It does not require any changes to the existing Struts code, but it enables Struts Controller components, Actions, to be treated as Spring Beans. In this process, Actions inherit the nature of the Spring Beans and, therefore, start looking a lot like Spring Controllers.
Slow and step-wise migration is possible with this process. Each Action could be replaced one at a time by the Spring Controllers without rewriting the application at once and interrupting the existing Web sequences.
2. Spring with Tiles
Another alternative, fully supported by the Spring framework, is to replace Struts Controllers and related components (Actions, Form Beans, etc.) with Spring MVC components while keeping Tiles as the pure “view” framework. Spring MVC does not have a specific alternative to Tiles, so architects may decide to keep their investments in Tiles and make them work through Spring MVC.
The one serious disadvantage of this approach is that you will effectively maintain two diverse Web frameworks in your Web application, which could result in a greater maintenance burden and training effort.
3. Complete Migration
Complete migration would mean total replacement of all the components of the Struts framework with Struts MVC. At the end of the process, no Struts-specific components would remain in the application.
Time to Spring Forward?
This article does not declare either framework better than the other. That is for you to decide, based on your understanding of the strengths and weaknesses of both and the architectural requirements at hand. In my opinion, Spring MVC has a brighter future, which is why I shared this guide for those who feel the same way and currently run large Struts-based applications. Those who are reasonably familiar with Struts and want to learn more about Spring in order to start adopting it also should find it useful.
Finally, one important feature of Spring that is not present in Struts and that is worth knowing is the upcoming Spring WebFlow framework. I recommend getting familiar with this flow-oriented framework as well if you plan to transition to Spring MVC.