Search code examples
struts2migrationstruts-1

Struts 1 to Struts 2 migration strategy


If I want to migrate Struts 1 to Struts 2, can I leave the JSP implementation in Struts 1 and rewrite the action class in Struts 2?

Can I use in web.xml both configurations for Struts 1 and Struts 2?


Solution

  • You have to rewrite both action classes and JSP, however you can reuse your business services if they are exist on the service layer. The same is for persistence layer.

    Note, if you can leave JSP implementation, then you should replace them with something that will work on the view layer. It could be html, javascript, another templating framework like freemarker or velocity. It could be SPA, or MPA application that communicates with the server via HTTP or web sockets. It's up to you how do you architect your application. Struts can parse usual HTTP requests (GET/POST) and REST with support of the plugin. A lot of plugins exist to help you to better use the framework.

    Struts1 is too old and can't work with the latest Struts2 because they have mismatch of dependencies of different versions. You should just leave Struts1 and migrate it to Struts2. It's straightforward process that takes less time rather that rewriting to another framework like Spring MVC.

    If you need more information about the migration process you can read this answer. However, a lot of information and code is already outdated comparing to the latest version of Struts and might not work the ideas remain the same.