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

14,434

Solution 1

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.

Solution 2

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

Solution 3

Try to read and compare the following articles:

See also: "Migrating from Struts2 to Spring MVC" question at stackoverflow.

Solution 4

Moving to either is essentially the same amount, and type, of work.

While there is a Struts 1 plugin in S2 that allows use of existing S1 action classes, as noted you still need to rewrite your JSP files, and your app would still suffer from S1's close ties to the servlet framework.

Share:
14,434

Related videos on Youtube

bogachkov
Author by

bogachkov

Updated on April 30, 2022

Comments

  • bogachkov
    bogachkov about 2 years

    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.