Struts 2 简明教程

Struts 2 - Overview

Struts2 是一个基于 MVC 设计模式的流行且成熟的 Web 应用程序框架。Struts2 不仅仅是 Struts 1 的一个新版本,而是一种对 Struts 架构的完全重写。

Struts2 is a popular and mature web application framework based on the MVC design pattern. Struts2 is not just a new version of Struts 1, but it is a complete rewrite of the Struts architecture.

Webwork 框架最初以 Struts 框架为基础,其目标是提供一个建立在 Struts 之上的增强和改进的框架,以便为开发人员简化 Web 开发。

The Webwork framework initially started with Struts framework as the basis and its goal was to offer an enhanced and improved framework built on Struts to make web development easier for the developers.

一段时间后,Webwork 框架和 Struts 社区携手合作创建了著名的 Struts2 框架。

After a while, the Webwork framework and the Struts community joined hands to create the famous Struts2 framework.

Struts 2 Framework Features

以下是一些可能迫使您考虑 Struts2 的强大功能 −

Here are some of the great features that may force you to consider Struts2 −

  1. POJO Forms and POJO Actions − Struts2 has done away with the Action Forms that were an integral part of the Struts framework. With Struts2, you can use any POJO to receive the form input. Similarly, you can now see any POJO as an Action class.

  2. Tag Support − Struts2 has improved the form tags and the new tags which allow the developers to write less code.

  3. AJAX Support − Struts2 has recognized the take over by Web2.0 technologies, and has integrated AJAX support into the product by creating AJAX tags, this function is very similar to the standard Struts2 tags.

  4. Easy Integration − Integration with other frameworks like Spring, Tiles and SiteMesh is now easier with a variety of integration available with Struts2.

  5. Template Support − Support for generating views using templates.

  6. Plugin Support − The core Struts2 behavior can be enhanced and augmented by the use of plugins. A number of plugins are available for Struts2.

  7. Profiling − Struts2 offers integrated profiling to debug and profile the application. In addition to this, Struts also offers integrated debugging with the help of built in debugging tools.

  8. Easy to Modify Tags − Tag markups in Struts2 can be tweaked using Freemarker templates. This does not require JSP or java knowledge. Basic HTML, XML and CSS knowledge is enough to modify the tags.

  9. Promote Less configuration − Struts2 promotes less configuration with the help of using default values for various settings. You don’t have to configure something unless it deviates from the default settings set by Struts2.

  10. View Technologies − Struts2 has a great support for multiple view options (JSP, Freemarker, Velocity and XSLT)

上面列出了 Struts 2 的 10 大特性,因此它成为企业就绪框架。

Listed above are the Top 10 features of Struts 2 which makes it as an Enterprise ready framework.

Struts 2 Disadvantages

虽然 Struts 2 带有一系列出色的特性,但当前版本(Struts 2)有一些限制,需要进一步改进。下面列出了一些要点 −

Though Struts 2 comes with a list of great features, there are some limitations of the current version - Struts 2 which needs further improvement. Listed are some of the main points −

  1. Bigger Learning Curve − To use MVC with Struts, you have to be comfortable with the standard JSP, Servlet APIs and a large & elaborate framework.

  2. Poor Documentation − Compared to the standard servlet and JSP APIs, Struts has fewer online resources, and many first-time users find the online Apache documentation confusing and poorly organized.

  3. Less Transparent − With Struts applications, there is a lot more going on behind the scenes than with normal Java-based Web applications which makes it difficult to understand the framework.

最后需要注意的是,一个好的框架应提供多种不同类型的应用程序可以利用的通用行为。

Final note, a good framework should provide generic behavior that many different types of applications can make use of it.

Struts 2 是最好的 Web 框架之一,被广泛用于开发富互联网应用程序 (RIA)。

Struts 2 is one of the best web frameworks and being highly used for the development of Rich Internet Applications (RIA).