简体   繁体   English

从Struts 1.2迁移 - > Struts2与Spring-MVC(主要是对Struts1.2 taglib支持)

[英]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? 主要问题:如果我的应用程序当前正在使用Struts 1.x - 并且我正在考虑迁移到用于MVC框架的EITHER Spring-MVC或Struts2 - 是否有任何一个可以更容易从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. 为了澄清,我不是在问SpringMVC或Struts2是否总体上更好(SO上有许多现有的Q来解决这个问题) - 从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. 从迁移的角度来看,我最感兴趣的一点是: 在JSP页面 中继续 (在开始时) 继续使用struts1.x的taglib,同时在后端更改为Struts2(或SpringMVC)的API。 (In other words, can either of these frameworks support Struts1.x's taglib as a plugin)? (换句话说,这些框架中的任何一个都可以支持Struts1.x的taglib作为插件)吗? [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. [注意:这不是一个长期的解决方案 - 但会减少集成的痛苦,因为JSP不需要立即重写。 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. 我正在开发一个应用程序,其MVC层是通过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. 我们也使用Spring IOC - 尽管该应用程序目前还没有Struts层和Spring的DI设备之间的强大集成。 (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.) (注意:这是我们在重构时计划纠正的内容,但我的理解是通过一些规划 - 即使使用Spring IOC + Struts2组合也可以正确/有效地完成。)

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 (ie 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. 作为改进/重构代码库的一部分 - 我们希望升级到更现代的MVC框架(以便消除对Action / Form类的需求,并在可能的情况下使用基于Annotation的配置等)但保持整体经典-MVC风格(即目前没有兴趣跳跃到JSF,Tapestry,GWT,Flex,Play等等。我明白这些是非常不同的东西 - 将它们混合在一起只是为了给出一个大致的想法..)此外,我的愿望是采用具有合理牵引力/动力的东西 - 因此为此推定Stripes。 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) 这似乎只是让Spring-MVC和Struts2成为竞争者(尽管如果有其他类似风格和强大的行业牵引力 - 我们肯定会考虑它)

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? 出于这个原因,如果其中任何一个支持Struts 1.2的taglib - 它将使切换/测试更容易(因为我们可以在新API中编写特定模块的“Control”实现 - 并让第二个服务器运行旧的Struts1 .2使用相同的jsps实现.QA测试在某种程度上将是“苹果到苹果”。这是否有意义,或者这种方法(如果可行的话)会导致比解决更多的麻烦?

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. 另外,如上所述,虽然我的主要问题是使用Spring-MVC或Struts2运行struts1.2的taglib - 我也对Struts2-vs-Spring-MVC的任何其他MIGRATION优势感兴趣。

如果将Strut1.2迁移到Spring MVC,如果我们在WEB-INF / lib中包含struts.jar,我们仍然可以在Spring MVC中使用strut1.2 taglib,这意味着你仍然可以使用bean:define,bean:write ..逻辑:现在,逻辑:等于...(Struts1.2 taglib)在JSP中,只有更改是struts 1.2表单taglib(html:text,html:error html:form ...)应该更改为spring form taglib( form:path,form:form,form:path,form:error ...)这样我们就可以通过formBackObject将表单字段绑定到命令类数据,referenceData或初始化命令数据,以使用spring MVC JSP特性

I have not seen support for Struts 1 taglib in any of these frameworks. 我没有在任何这些框架中看到对Struts 1 taglib的支持。

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 Struts2的一些小优点:有一些关于将应用程序从Struts1迁移到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 Struts2中甚至还有一个Struts1插件允许你在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. 不幸的是,同样的引用说你必须转换旧的JSP,这不是一件容易的事。

Try to read and compare the following articles: 尝试阅读并比较以下文章:

See also: "Migrating from Struts2 to Spring MVC" question at stackoverflow. 另请参阅:stackoverflow中的“从Struts2迁移到Spring MVC”问题。

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. 虽然一个Struts插件1 S2中允许使用现有的S1动作类,如注意你仍然需要重写你的JSP文件和您的应用程序仍然会从S1的密切联系的Servlet框架受到影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM