从Struts的1有没有人迁移到另一台Web框架? [英] Has anyone migrated from Struts 1 to another web framework?

查看:231
本文介绍了从Struts的1有没有人迁移到另一台Web框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的当前项目,我们一直在使用的Struts 1在过去的几年里,和...恩... Struts是显示出它的年龄。我们正在慢慢地迁移我们的前端code到Ajax客户端消耗XML从服务器。我想知道,如果你们已经迁移遗留Struts应用到一个不同的框架,以及什么样的挑战,你在面对这样做。

On my current project, we've been using Struts 1 for the last few years, and ... ahem ... Struts is showing its age. We're slowly migrating our front-end code to an Ajax client that consumes XML from the servers. I'm wondering if any of you have migrated a legacy Struts application to a different framework, and what challenges you faced in doing so.

推荐答案

当然。从Struts的移动到了AJAX框架是一个非常解放的经验。 (虽然我们用JSON而不是XML,更容易解析)。但是,你需要知道它是有效的应用程序的完全重写。

Sure. Moving from Struts to an AJAX framework is a very liberating experience. (Though we used JSON rather than XML. Much easier to parse.) However, you need to be aware that it's effectively a full rewrite of your application.

相反的MVC经典的数据库/ JSP /行动计划,你会发现自己移动到一个Servlet / Javascript的计划,让该模型是由重HTTP GET psented $ P $的要求,操作由psented重新preOST / PUT / DELETE请求,并且该视图上通过网络浏览器飞呈现。这导致一些有趣的挑战在每个领域:

Instead of the classic Database/JSP/Actions scheme for MVC, you'll find yourself moving to a Servlet/Javascript scheme whereby the model is represented by HTTP GET requests, actions are represented by POST/PUT/DELETE requests, and the view is rendered on the fly by the web browser. This leads to interesting challenges in each area:

服务器端 - 在服务器端,你需要制定一个标准,公开数据到客户端。最简单的,最简单的方法是采用一个 REST 方法最适合您的数据的层次结构。这是非常简单的实现使用servlet,但Sun公司还开发了一个 Java 1.6的方案使用属性看起来pretty的凉爽。

Server Side - On the server side you will need to develop a standard for exposing data to the client. The simplest and easiest method is to adopt a REST methodology that best matches your data's hierarchy. This is fairly simple to implement with servlets, but Sun also has developed a Java 1.6 scheme using attributes that looks pretty cool.

在服务器端的另一个方面是选择一个传输协议。我知道你已经提到的XML,但你可能要重新考虑。 XML解析器浏览器之间的差别很大。一个浏览器可能使文档根目录的第一个孩子,另一个可能会添加一个特殊的内容对象,他们都解析空白不同。更糟的是,正常化()函数似乎并没有被正确的主流浏览器实现的。这意味着XML解析容易充满黑客。

Another aspect of the server side is to choose a transmission protocol. I know you mentioned XML already, but you might want to reconsider. XML parsers vary greatly between browsers. One browser might make the document root the first child, another one might add a special content object, and they all parse whitespace differently. Even worse, the normalize() function doesn't seem to be correctly implemented by the major browsers. Which means that XML parsing is liable to be full of hacks.

JSON 是更容易分析,并在其结果更加一致。 :JavaScript与ActionScript(闪光)既可以直接转化JSON对象。这使得访问数据的XY或x [Y]一个简单的事情。也有大量的API来处理JSON的各种语言可以想象的。因为它很容易解析,它几乎支持比XML更好!

JSON is much easier to parse and more consistent in its results. Javascript and Actionscript (Flash) can both translate JSON directly to objects. This makes accessing the data a simple matter of x.y or x[y]. There are also plenty of APIs to handle JSON in every language imaginable. Because it's so easy to parse, it's almost supported BETTER than XML!

客户端 - 你要碰到的第一个问题是,没有人知道如何编写JavaScript的事实。尤其是那些谁认为他们做的。如果您有任何的Javascript的书,现在扔窗外。有实际的语言没有很好的书,因为它们都遵循同样的黑客的格局没有真正深入到自己在做什么。

Client Side - The first issue you're going to run into is the fact that no one understands how to write Javascript. ESPECIALLY those who think they do. If you have any books on Javascript, throw them out the window NOW. There are practically no good books on the language as they all follow the same "hacking" pattern without really diving into what they are doing.

从最低的水平,你的团队将需要对JavaScript的开发辅导培训。先从 JavaScript客户端指南。这是的实际上的对语言信息源。下一站是道格拉斯Crockford的视频于JavaScript。我不与他的一切不得不说同意,但他对语言的少数专家之一。

From the lowest level, your team is going to need remedial training on Javascript development. Start with the Javascript Client Guide. It's the de facto source of information on the language. The next stop is Douglas Crockford's videos on Javascript. I don't agree with everything he has to say, but he's one of the few experts on the language.

一旦你得到了下来,考虑一下框架,如果有的话,您要使用。一般来说,我不喜欢的东西,如Prototype和MooTools的。他们往往采取简单的问题,使情况变得更糟。尽管如此,你可以随时来评​​估这些工具,并决定他们是否会为你工作。

Once you've got that down, consider what frameworks, if any, you want to use. Generally speaking, I dislike stuff like Prototype and Mootools. They tend to take a simple problem and make it worse. None the less, you can feel free to evaluate these tools and decide if they'll work for you.

如果你确实觉得你生活中不可缺少的框架,因为你的团队是太缺乏经验,然后 GWT 可能适合该法案。 GWT可以让你快速编写DHTML的Web应用程序在Java中code,然后将其编译为Javascript。问题是,你放弃的灵活性,大量做这个。 JavaScript语言是远远强过GWT暴露。但是,GWT并让Java开发人员加快速度更快。因此,选择你的战场。

If you absolutely feel that you cannot live without a framework because your team is too inexperienced, then GWT might fit the bill. GWT allows you to quickly write DHTML web apps in Java code, then compile them to Javascript. The PROBLEM is that you're giving up massive amounts of flexibility by doing this. The Javascript language is far more powerful than GWT exposes. However, GWT does let Java developers get up to speed faster. So pick your battles.

这些是我能想到的重点领域。我可以说,你会如释重负地叹了口气,一旦你得到的支柱你的应用程序。它可以是一个有点野兽。特别是如果你有经验的开发人员的工作对你的Struts的模型。 : - )

Those are the key areas I can think of. I can say that you'll heave a sigh of relief once you get struts out of your application. It can be a bit of a beast. Especially if you've had inexperienced developers working on your Struts model. :-)

有任何疑问?

修改1:我忘了补充一点,你的团队应该研究 W3C规范宗教。这些都是在现代浏览器提供给您的API。如果您使用DOM API的0人捉(如document.forms ['MyForm的']。blah.value的document.getElementById(嗒嗒)值,而不是),迫使他们抄写整个DOM 1规范,直到他们明白它的顶部至底部。

Edit 1: I forgot to add that your team should study the W3C specs religiously. These are the APIs available to you in modern browsers. If you catch anyone using the DOM 0 APIs (e.g. document.forms['myform'].blah.value instead of document.getElementById("blah").value) force them to transcribe the entire DOM 1 specification until they understand it top to bottom.

编辑2:另一个需要考虑的关键问题是如何记录你看中的新的AJAX应用程序。 REST风格的接口能够很好的被记录在一个Wiki。我所做的是一个有上市的每一项服务和描述的顶级页面。通过点击服务路径上,你会被带到与每个子路径的详细信息的文档。从理论上讲,该方案可以为你所需要的树去记录深。

Edit 2: Another key issue to consider is how to document your fancy new AJAX application. REST style interfaces lend themselves well to being documented in a Wiki. What I did was a had a top level page that listed each of the services and a description. By clicking on the service path, you would be taken to a document with detailed information on each of the sub-paths. In theory, this scheme can document as deep as you need the tree to go.

如果你去使用JSON,你需要制定一个计划,以文件的对象。我刚上市在维基可能的属性文件。这非常适用于简单的对象树,但可以用更大,更复杂的对象复杂。你可以考虑用类似IDL或WebIDL在这种情况下补充。 (不能比XML DTD和架构更糟糕; - 。))

If you go with JSON, you will need to develop a scheme to document the objects. I just listed out the possible properties in the Wiki as documentation. That works well for simple object trees, but can get complex with larger, more sophisticated objects. You can consider supplementing with something like IDL or WebIDL in that case. (Can't be much worse than XML DTDs and Schemas. ;-))

在DHTML code是比较经典的文档中的一个位。您可以使用一个工具,如 JSDoc 创建Javadoc风格的文档。这里还有一点需要注意。 Javascript的code不适合很好地被记载IN- code。如果没有其他原因,它腌下载的事实。然而,你可能会发现自己经常写code,它作为一个有凝聚力的对象,而不是在幕后为这样一个目标codeD。因此,最好的解决方案是创建一个重新present和记录的Javascript对象JSDoc框架文件。

The DHTML code is a bit more classical in its documentation. You can use a tool like JSDoc to create JavaDoc-style documentation. There's just one caveat. Javascript code does not lend itself well to being documented in-code. If for no other reason that the fact that it bloats the download. However, you may find yourself regularly writing code that operates as a cohesive object, but is not coded behind the scenes as such an object. Thus the best solution is to create JSDoc skeleton files that represent and document the Javascript objects.

如果你使用GWT,文件应该是一个没有脑子。

If you're using GWT, documentation should be a no-brainer.

这篇关于从Struts的1有没有人迁移到另一台Web框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆