Browse DevX
Sign up for e-mail newsletters from DevX


Spring Your Struts Apps Ahead: The Struts-to-Spring Migration : Page 4

Find out what it takes to migrate Struts applications to Spring MVC. You'll learn not only how to transform Struts applications into Spring MVC applications, but also the logical mapping between the two frameworks and how key Struts concepts relate to Spring MVC concepts.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 first—and completely painless—step 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.

Edmon Begoli a software architect with 14 years of professional experience on large commercial and federal software projects. He is a member of the R&D staff at Oak Ridge National Laboratory.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date