java Struts 1.x 与 Struts 2.x

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5867970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 13:12:23  来源:igfitidea点击:

Struts 1.x vs Struts 2.x

javastruts2struts-1

提问by Codemwnci

I have reviewed a few Struts 1 vs 2 questions on SO but none seem to answer the question in the perspective that I am looking at it with.

我已经回顾了一些关于 SO 的 Struts 1 vs 2 问题,但似乎没有人从我正在研究的角度回答这个问题。

I am about to start work architecting a new system, a complete re-engineering of a very old desktop application. The goal is to make it web based, add more functionality, make it more usable etc (the usual reengineering reasons).

我即将开始构建一个新系统,一个非常旧的桌面应用程序的完全重新设计。目标是使其基于网络,添加更多功能,使其更可用等(通常的重新设计原因)。

The team who will be developing the system are mainly Java developers and have worked on Struts 1.x extensively over the past 5 years.

将开发该系统的团队主要是 Java 开发人员,并且在过去 5 年中广泛地致力于 Struts 1.x。

The system is intended to live for many years to come, so the idea of re-engineering again in 3-5 years time when a better framework comes out is not an option. It is not intended to heavily use AJAX.

该系统打算在未来许多年使用,因此在 3-5 年之后出现更好的框架时再次重新设计的想法是不可行的。它不打算大量使用 AJAX。

My question, is why would I bother moving to Struts 2 when my team are so experienced with Struts 1.x. I understand that there are some improvements, but I worry that the time lost in getting the team up to speed, rework due to incorrect usage etc will far outweigh any benefit we would get from Struts 2. We like Struts 1, it does what we need to it do, and all the design patterns, standards, best practices etc are in place.

我的问题是,当我的团队对 Struts 1.x 如此有经验时,我为什么还要费心转向 Struts 2。我知道有一些改进,但我担心在让团队跟上速度、因使用不当而返工等方面浪费的时间将远远超过我们从 Struts 2 中获得的任何好处。我们喜欢 Struts 1,它做我们想做的事需要这样做,并且所有设计模式、标准、最佳实践等都已到位。

Are there any killer features with Struts 2 or serious problems I don't know about in Struts 1 that would sway the decision to stay with Struts 1.

Struts 2 中是否有任何杀手级功能或我不知道 Struts 1 中的严重问题会影响继续使用 Struts 1 的决定。

回答by planetjones

If you are building a system from scratch I would definitely move onto version 2.x of Struts. The learning curve will not be great for a Struts 1.x team, but you will be able to take advantage of an up-to-date MVC framework.

如果您是从头开始构建系统,我肯定会转向 Struts 2.x 版。对于 Struts 1.x 团队来说,学习曲线不会很好,但您将能够利用最新的 MVC 框架。

For me the two main features of Struts 2.x which will enhance productivity are:

对我来说,Struts 2.x 的两个主要特性将提高生产力:

  • Built in AJAX support
  • No more ActionForms - you can bind directly into Domain Objects if you want, so this intermediate step has gone.
  • 内置 AJAX 支持
  • 没有更多的 ActionForms - 如果需要,您可以直接绑定到域对象,所以这个中间步骤已经过去了。

If it's a big project you're working on, you might want to look at a component framework e.g. JSF 2 or Wicket. If you're determined to stay on an Action based framework then I personally find Stripes a more productive framework.

如果这是一个大型项目,您可能需要查看组件框架,例如 JSF 2 或 Wicket。如果您决定继续使用基于 Action 的框架,那么我个人认为 Stripes 是一个更高效的框架。

回答by duffymo

Struts 1.x is 2000 vintage technology. Why on earth would you even consider sticking with it on a brand-new app?

Struts 1.x 是 2000 年的老式技术。你到底为什么会考虑在一个全新的应用程序上坚持使用它?

The biggest drawback that I can see is that Struts locks you into a JSP-based, browser UI. Struts Actions are reusable only within the framework. You'll have a hard time seamlessly integrating a mobile device into that system if you need to.

我能看到的最大缺点是 Struts 将您锁定在基于 JSP 的浏览器 UI 中。Struts Actions 只能在框架内重用。如果需要,您将很难将移动设备无缝集成到该系统中。

I'd start thinking about web services, preferrably REST-based, and AJAX. The world has changed. I'd look into alternatives to Struts, like Spring or Play. Picking up a new web framework wouldn't be that big a deal, but the benefits could be worth it.

我会开始考虑 Web 服务,最好是基于 REST 的和 AJAX。世界已经改变。我会研究 Struts 的替代品,比如 Spring 或 Play。选择一个新的 Web 框架没什么大不了的,但它的好处可能是值得的。

Those employees that have done nothing but work with an outdated framework for the last five years will thank you, too. Time for new skills.

那些在过去五年里只用过时的框架工作的员工也会感谢你。是时候学习新技能了。

UPDATE: If you've tried, and can't be late, and too many constraints, then I'd say you already know your answer. What are you hoping to get by coming here? I don't see an argument that you've failed to think through.

更新:如果您已经尝试过,并且不能迟到,并且有太多限制,那么我会说您已经知道答案了。你来这里希望得到什么?我没有看到你没有考虑过的论点。

回答by Pravin

Given that your have a team with good experience in Struts 1.x and your product is stable as well, I don't see a great reason to migrate to Struts 2. Apache too seem to agree that http://struts.apache.org/roadmap.html#migrate_s1.

鉴于您的团队在 Struts 1.x 方面具有丰富的经验,而且您的产品也很稳定,我认为没有什么好的理由迁移到 Struts 2。Apache似乎也同意http://struts.apache. org/roadmap.html#migrate_s1

回答by leonbloy

I'd think instead of asking "Stick with Struts1 or move to Struts2?" you'd better ask "Stick with Struts1 or move to a modern action based MVC web framework?". Why to move ? Because Struts1 is old and (frankly) sucks. Why not to move? Because we must learn a new framework. Granted, you know your resources, you must do the evaluation. But bear in mind that modern action based frameworks (Struts2, SpringMVC, Stripes) are quite easy to learn, and more so if your teams already knows Struts1.

我会想而不是问“坚持使用 Struts1 还是转向 Struts2?” 你最好问“坚持使用 Struts1 还是转向基于现代动作的 MVC Web 框架?”。为什么要移动?因为 Struts1 很旧而且(坦率地说)很烂。为什么不能动?因为我们必须学习一个新的框架。当然,您知道您的资源,您必须进行评估。但请记住,现代基于动作的框架(Struts2、SpringMVC、Stripes)非常容易学习,如果您的团队已经了解 Struts1,则学习更容易。

Myself, I've have migrated from Struts to Struts2 and now I wouldn't like to return to Struts1 programming (those clumsy ActionForms!). I think Struts2 is much better. But one must also consider that Struts2 has also its weak points, the project does not seem very healty and the community does not seem very active. The jump from Struts1 to Struts2 is not big, but is not as small as a version change ("Struts2" is a misnomer), and it is probably not smaller that the jump to SpringMVC, so I'd suggest to consider it (or Stripes).

我自己已经从 Struts 迁移到 Struts2,现在我不想回到 Struts1 编程(那些笨拙的 ActionForms!)。我认为Struts2要好得多。但是也要考虑到Struts2也有它的弱点,项目看起来不太健康,社区也不太活跃。从 Struts1 到 Struts2 的跳跃并不大,但并不像版本变化那么小(“Struts2”用词不当),而且它可能不比跳跃到 SpringMVC 小,所以我建议考虑一下(或条纹)。

回答by Umesh Awasthi

Well the main reason is moving to struts 2.x in place of struts 1.x is struts 1.x is in maintenance phase now not in much active development.

嗯,主要原因是转向 struts 2.x 代替 struts 1.x 是 struts 1.x 处于维护阶段,现在没有太多积极的开发。

now when it starts with a team who have good understanding of struts 1.x is that they will get the underlying system quickly.but before let me to put one point in a clear manner. struts1.x has no similarity with struts 2.x the only similarity is the name inherited from the parents. struts2 has following advantages.

现在,当一个团队对 struts 1.x 有很好的理解时,他们会很快得到底层系统。但在此之前,让我清楚地说明一点。struts1.x 与 struts 2.x 没有相似之处,唯一的相似之处是从父母那里继承的名字。struts2 有以下优点。

  1. Action based framework
  2. A strong Ajax support
  3. Interceptors approach (core of framework) 4 Decoupled from the Serve let API which means plain POJO so unit testing will be much much easier
  1. 基于行动的框架
  2. 强大的 Ajax 支持
  3. 拦截器方法(框架的核心) 4 与 Serve let API 解耦,这意味着简单的 POJO 所以单元测试会容易得多

but my point is simple struts2 and struts1 only similar in terms of name but in terms of underlying architecture they are quite different.

但我的观点是简单的 struts2 和 struts1 仅在名称方面相似,但在底层架构方面却大不相同。

回答by p27

in struts2.0 there are more feature and advantage , in struts2.0 there is no form beam, a good and power full validation framework and most imported in struts2.0 for every request there is one instance of action but in sturts1.x only one instance of action for hole application.

在 struts2.0 中有更多的特性和优势,在 struts2.0 中没有表单梁,一个好的和强大的完整验证框架,并且大多数在 struts2.0 中导入,每个请求都有一个动作实例,但仅在 sturts1.x 中孔应用的一个动作实例。

so choice is yours . :)

所以选择是你的。:)

回答by Vignesh Ramachandran

More Generally, Struts 2.x layered framework compare to Struts 1.x. For example in data layer , Struts 2.x has DO layer between VO and DAO.. Similarly other features are mentioned in the below link..

更一般地说,Struts 2.x 分层框架与 Struts 1.x 相比。例如在数据层,Struts 2.x 在 VO 和 DAO 之间有 DO 层。类似的其他特性在下面的链接中提到。

http://struts.fromdev.com/2008/08/struts-1-vs-struts-2.html..

http://struts.fromdev.com/2008/08/struts-1-vs-struts-2.html..

Since your team has more experienced with struts 1.x , i don't think it will take more time to migrate your code in to struts 2.x.

由于您的团队对 struts 1.x 有更多经验,我认为将您的代码迁移到 struts 2.x 不会花费更多时间。

Please be specific what kind of difference u are expecting..

请具体说明你期待什么样的差异..