1、英文翻译资料 A.英文原文 Struts Apache Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model-view-controller (MVC) architecture. It was originally created by Craig McClanahan and donated to t
2、he Apache Foundation in May, 2000. Formerly located under the Apache Jakarta Project and known as Jakarta Struts, it became a top level Apache project in 2005. Design goals and overview In a standard Java EE web application, the client will typically submit information to the server via a web form.
3、The information is then either handed over to a Java Servlet which processes it, interacts with a database and produces an HTML-formatted response, or it is given to a JavaServer Pages (JSP) document which intermingles HTML and Java code to achieve the same result. Both approaches are often consider
4、ed inadequate for large projects because they mix application logic with presentation and make maintenance difficult. The goal of Struts is to cleanly separate the model (application logic that interacts with a database) from the view (HTML pages presented to the client) and the controller (instance
5、 that passes information between view and model). Struts provides the controller (a servlet known as ActionServlet) and facilitates the writing of templates for the view or presentation layer (typically in JSP, but XML/XSLT and Velocity are also supported). The web application programmer is responsi
6、ble for writing the model code, and for creating a central configuration file struts-config.xml which binds together model, view and controller. Requests from the client are sent to the controller in the form of “Actions” defined in the configuration file; if the controller receives such a request i
7、t calls the corresponding Action class which interacts with the application specific model code. The model code returns an “ActionForward”, a string telling the controller which output page to send to the client. Information is passed between model and view in the form of special JavaBeans. A powerf
8、ul custom tag library allows it to read and write the content of these beans from the presentation layer without the need for any embedded Java code. Struts also supports i18n (internationalization), provides facilities for the validation of data submitted by web forms, and includes a template mecha
9、nism called “Tiles” which (for instance) allows the presentation layer to be composed from independent header, footer, and content components. Competing MVC frameworks Although Struts is a well documented, mature and popular framework for building front ends to Java applications, it is facing new ch
10、allenges from newer “light weight” MVC frameworks such as Spring MVC, Stripes and Tapestry. The new XForms standards and frameworks may also be another option to building complex web Form validations with Struts in the future. The WebWork framework spun off from Apache Struts several years ago, aimi
11、ng to offer enhancements and refinements while retaining the same general architecture of the original Struts framework. However, it was announced in December 2005 that Struts would re-merge with WebWork. WebWork 2.2 has been adopted as Apache Struts 2, which reached its first full release in Februa
12、ry 2007. Sun recently brought out a new addition to the Java platform, called JavaServer Faces (JSF). Aside from the original framework, the Apache Struts project also offers a JSF-based framework called Shale. Other MVC frameworks that are not J2EE based include Ruby on Rails, WebObjects, Django, C
13、atalyst, TurboGears, CakePHP, Symfony (for PHP), Zend, Achievo ATK, and CodeIgniter (for PHP). Struts4php is a version of the Struts framework for the PHP web scripting language. Girders is a port of the Struts framework in C# for Microsoft .NET. Extracted from http:/struts.apache.org/ B.原文的翻译 Strut
14、s Struts 是 Apache 软件基金会( ASF)赞助的一个开源项目。它最初是 Jakarta 项目中的一个子项目,并在 2004 年 3 月成为 ASF 的顶级项目。它通过采用 Java Servlet/JSP 技术,实现了基于 Java EE Web 应用的 Model-V iew-Controller( MVC)设计模式的应用框架( Web Framework),是 MVC 经典设计模式中的一个经典产品。 MVC 结构 在 Struts 中,已经由一个名为 ActionServlet 的 Servlet 充当控制器( Controller ) 的 角 色 , 根 据 描 述 模
15、型 、 视 图 、 控 制 器 对 应 关 系 的 struts-config.xml 的配置文件,转发视图( View)的请求,组装响应数据模型( Model)。在 MVC 的 模型( Model)部分,经常划分为两个主要子系统(系统的内部数据状态与改变数据状态的逻辑动作),这两个概念子系统分别具体对应 Struts 里的 ActionForm 与 Action 两个需要继承实现超类。 在这里, Struts 可以与各种标准的数据访问技术结合在一起,包括 Enterprise Java Beans( EJB) , JDBC 与 JNDI。在 Struts 的视图( View) 端,除了使用标
16、准的 JavaServer Pages( JSP)以外,还提供了大量的标签库使用,同时也可以与其他表现层组件技术(产品)进行整合,比如 Velocity Templates, XSLT 等。通过应用 Struts 的框架,最终用户可以把大部分的关注点放在自己的业务逻辑( Action)与 映射关系的配置文件( struts-config.xml)中。 发展历程 在 Java EE 的 Web 应用发展的初期,除了使用 Servlet 技术以外,普遍是在 JavaServer Pages ( JSP)的源代码中,采用 HTML 与 Java 代码混合的方式进行开发。因为这两种方式不可避免的要把表
17、现与业务逻辑代码混合在一起,都给前期开发与后期维护带来巨大的复杂度。为了摆脱上述的约束与局限,把业务逻辑代码从表现层中清晰的分离出来, 2000 年, Craig McClanahan 采用了 MVC 的设计模式开发 Struts。后来该框架产品 一度被认为是最广泛、最流行 JAVA 的 WEB 应用框架。 2006 年, WebWork 与 Struts 这两个优秀的 Java EE Web 框架( Web Framework)的团体,决定合作共同开发一个新的,整合了 WebWork 与 Struts 优点,并且更加优雅、扩展性更强的框架,命名为 “ Struts 2”,原 Struts 的
18、 1.x 版本产品称为” Struts 1”。 至此, Struts 项目并行提供与维护两个主要版本的框架产品 Struts 1 与 Struts 2。 充满竞争的 MVC 框架 虽然 Struts 的是成熟的和流行的框架,建设前端 Java 应用,它正面临新的挑战,从较新的”轻量”的 MVC 框架,如 Spring 的 MVC , Stripes 和 Tapestry 。新的 XForms 标准和框架,也可能是另一种选择,以建立复杂的 Web 窗体验证与Struts 的未来。 在 WebWork 框架脱离 Apache 的 Struts 的几年前,以提供改进和完善,同时保持了相同的一般建筑的原始 Struts 框架。然而,它在 2005 年 12 月宣布,该框架将重新合并 WebWork 。 WebWork 2.2 已获得通过,成 为 Apache 的 Struts的 2 ,达到了第一个完整的版本于 2007 年 2 月。