Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migration from Struts 1.2 -> Struts2 vs Spring-MVC (primarily vis-a-vis Struts1.2 taglib support)

Primary Question: If my app is CURRENTLY using Struts 1.x - and I am considering migrating to EITHER Spring-MVC or Struts2 for the MVC-framework - is there anything about either one that would make it easier to migrate from Struts1.2?

To clarify, I am NOT asking whether SpringMVC or Struts2 is better overall (there are a number of existing Q's on SO that address this) - just which one is easier to migrate to from Struts1.2.

The point that I am most interested in from a migration perspective: possibility of continuing (in the beginning) to use struts1.x's taglib within the JSP pages, while changing to Struts2's (or SpringMVC's) API on the backend. (In other words, can either of these frameworks support Struts1.x's taglib as a plugin)? [Note: this is not intended as a long term solution - but would reduce integration pain, since the JSPs would not need to be immediately rewritten. I assume this question makes sense - if not, please expain why]

With that said, I am of course interested in any other migration advantages.


Some background:

I am working on an app whose MVC layer is written via Struts 1.2. We are also using Spring IOC - though the app doesn't currently have strong integration between the Struts layer and Spring's DI facilities. (Note: This is something that we plan on correcting when we refactor, but my understanding is that with a bit of planning - this can be done properly/efficiently even when using a Spring IOC+Struts2 combination.)

As part of improving/refactoring the codebase - we would like to upgrade to a more modern MVC framework (so as to eliminate the need for Action/Form classes, and to use Annotation-based configuration when possible, etc) but keep the overall classic-MVC style (i.e. not currently interested in making the leap to JSF, Tapestry, GWT, Flex, Play, etc. I understand that these are very very different things - lumping them together just to give a general idea..) Also, the desire is to go with something with reasonable traction/momentum - so ruling Stripes out for that reason. This seems to only leave Spring-MVC & Struts2 as contenders (though if there is something else with a similar style and with strong industry traction - we would certainly consider it)

It is a given that switching to either of these would require a descent amount of work - but the plan would be to do it on a modular level. For that reason, if either of these supported Struts 1.2's taglib - it would make switching/testing much easier (as we could then code a particular module's "Control" implementation in the new API - and have a 2nd server run the old Struts1.2 implementation using the same jsps. QA testing would then be "apples to apples" in a way. Does this make sense, or would this approach (if even feasible) lead to more headaches than it would resolve?

Also, as stated above, while my primary question is about running struts1.2's taglib with either Spring-MVC or Struts2 - I am also interested in any other MIGRATION advantages for Struts2-vs-Spring-MVC.

like image 758
bogachkov Avatar asked Aug 09 '10 00:08

bogachkov


People also ask

What is the difference between struts1 and Struts2?

Struts 1 supports separate Request Processors (lifecycles) for each module, but all the Actions in the module must share the same lifecycle. Struts 2 supports creating different lifecycles on a per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed.

Why is Struts2 used?

Struts2 UI tags are used to generate HTML markup language, binding HTML form data to action classes properties, type conversion, validation, and i18n support.


2 Answers

If migrate Strut1.2 to Spring MVC, if we include the struts.jar in WEB-INF/lib , we still can use strut1.2 taglib in Spring MVC, that means you still can use bean:define, bean:write... logic:present, logic:equal ... (Struts1.2 taglib) in JSP , only change is struts 1.2 form taglib (html:text,html:error html:form ...) should be changed to spring form taglib (form:path, form:form,form:path,form:error ...) so that we can bind form fields to command class data , referenceData or initialized command data by formBackObject to use spring MVC JSP feature

like image 101
John Avatar answered Oct 19 '22 23:10

John


I have not seen support for Struts 1 taglib in any of these frameworks.

Some minor Struts2 advantages: There are a few official references about migrating applications from Struts1 to Struts2 - http://struts.apache.org/2.2.3.1/docs/migration-strategies.html - http://struts.apache.org/2.2.3.1/docs/migration-tools.html

There is even a Struts1 plugin in Struts2 that allows you to run your actions in Struts2 - http://struts.apache.org/2.2.3.1/docs/struts-1-plugin.html

Unfortunately, this same references say that you have to convert your old JSP's and that is not an easy task.

like image 34
madth3 Avatar answered Oct 20 '22 01:10

madth3