从 Struts 1.2 迁移 -> Struts2 与 Spring-MVC(主要是相对于 Struts1.2 taglib 支持)
主要问题:如果我的应用程序当前使用 Struts 1.x - 并且我正在考虑迁移到 Spring-MVC 或 Struts2 的 MVC 框架 - 是否有任何一个可以使从 Struts1 迁移变得更容易.2?
澄清一下,我并不是在问 SpringMVC 还是 Struts2 总体上哪个更好(SO 上有许多现有的问题可以解决这个问题) - 只是问哪个更容易从 Struts1 迁移到。 2.
从迁移的角度来看,我最感兴趣的一点:继续(一开始)在 JSP 页面中使用 struts1.x 的 taglib 的可能性,同时更改到后端的Struts2(或SpringMVC)API。(换句话说,这些框架中的任何一个都可以支持Struts1.x的taglib作为插件)吗? [注意:这并不是一个长期解决方案 - 但会减少集成的痛苦,因为 JSP 不需要立即重写。我认为这个问题是有道理的 - 如果没有,请解释原因]
话虽如此,我当然对任何其他迁移优势感兴趣。
一些背景:
我正在开发一个应用程序,其MVC层是通过Struts 1.2编写的。我们还使用 Spring IOC - 尽管该应用程序目前在 Struts 层和 Spring 的 DI 设施之间没有强大的集成。 (注意:这是我们在重构时计划纠正的问题,但我的理解是,通过一些规划 - 即使使用 Spring IOC+Struts2 组合,也可以正确/有效地完成此操作。)
作为改进/重构代码库的一部分 - 我们希望升级到更现代的 MVC 框架(以便消除对 Action/Form 类的需要,并在可能的情况下使用基于注释的配置等),但保持整体经典 MVC 风格(即目前对跳转到 JSF、Tapestry、GWT、Flex、Play 等不感兴趣。我知道这些是非常不同的东西 - 将它们放在一起只是为了给出一个总体想法。 )此外,我们的愿望是选择具有合理牵引力/动力的东西 - 因此因此将 Stripes 排除在外。这好像就只剩下Spring-MVC & 了。 Struts2 作为竞争者(尽管如果有其他类似风格且具有强大行业吸引力的东西 - 我们肯定会考虑它)
众所周知,切换到其中任何一个都需要大量工作 - 但计划是在模块化级别上进行。出于这个原因,如果其中任何一个支持 Struts 1.2 的 taglib - 它将使切换/测试变得更加容易(因为我们可以在新 API 中编写特定模块的“控制”实现 - 并让第二个服务器运行旧的 Struts1 .2 使用相同的 QA 测试的实现在某种程度上会是“同类”,或者这种方法(如果可行的话)会导致比它能解决的更多麻烦吗
? ,虽然我的主要问题是关于使用 Spring-MVC 或 Struts2 运行 struts1.2 的 taglib - 我也对 Struts2-vs-Spring-MVC 的任何其他迁移优势感兴趣。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果将 Strut1.2 迁移到 Spring MVC,如果我们在 WEB-INF/lib 中包含 struts.jar,我们仍然可以在 Spring MVC 中使用 strut1.2 taglib,这意味着您仍然可以使用 bean:define、bean:write 。 JSP中的logic:present,logic:equal ...(Struts1.2 taglib),唯一的变化是struts 1.2 form taglib(html:text,html:error html:form ...)应该改为spring form taglib( form:path, form:form,form:path,form:error ...)这样我们就可以将表单字段绑定到命令类数据,referenceData或通过formBackObject初始化的命令数据以使用Spring MVC JSP功能
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
我还没有在这些框架中看到对 Struts 1 taglib 的支持。
Struts2 的一些小优点:
有一些关于将应用程序从 Struts1 迁移到 Struts2 的官方参考资料
- http://struts.apache.org/2.2.3.1/docs/迁移策略.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/struts-1-plugin.html
不幸的是,同样的参考文献说您必须转换旧的 JSP,这不是一件容易的事。
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.
尝试阅读并比较以下文章:
另请参阅:"从Struts2 到 Spring MVC” stackoverflow 上的问题。
Try to read and compare the following articles:
See also: "Migrating from Struts2 to Spring MVC" question at stackoverflow.
转移到任何一个基本上都是相同数量和类型的工作。
虽然 S2 中有一个 Struts 1 插件允许使用现有的 S1 操作类,但如上所述,您仍然需要重写 JSP 文件,并且您的应用程序仍然会受到 S1 与 servlet 框架紧密联系的影响。
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.