Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Apache Struts is a free open-source framework for creating Java web applications. For more about the Apache Struts project, visit the project web site. For other community-supported resources, visit the Struts 2 Wiki.

Getting Started

The documentation is grouped into three areas.

...

An overview of all three areas is available.

(lightbulb) Visit the Struts 2 Wiki for other community-support resources.

Apache Struts 2

...

Apache Struts 2 helps you create an extensible development environment for your application, based on industry standards and proven design patterns.

Struts is a Model View Controller framework. Struts provides Controller and View components, and integrates with other technologies to provide the Model. The framework's Controller acts as a bridge between the application's Model and the web View.

To make it easier to present dynamic data, the framework includes its own library of markup tags. The tags interact with the framework's validation and internationalization features, to ensure that input is correct and output is localized. The tag library can be used with JSP, FreeMarker, or Velocity.

When a request is received, the Controller invokes an Action class. The Action class examines or updates the application's state by consulting the Model (or, preferably, an interface representing the Model). To transfer data between the Model and the View, properties can be placed on the Action class, or on a plain old JavaBean.

Most often, the Model is represented as a graph of JavaBean objects. The Model should do the "heavy lifting", and the Action will act as a "traffic cop" or adapter. The framework provides sophisticated, automatic type conversion to simplify transfering data between rich domain objects and text-only HTTP requests.

Struts 2 architecture in a nutshell

Architecture in a Nutshell

  1. The web browser requests the page
  2. The Filter Dispatcher looks at the request and determines the appropriate Action<
  3. The Interceptors automatically apply common functionality to the request like workflow, validation, and file upload handling
  4. The Action method executes, usually storing and/or retrieving information from a database
  5. The Result renders the output, be it HTML, images, or PDF, to the browser

Struts Tags in a nutshell

The Struts Tags help you create rich web applications with a minimum of coding. Often, much of the coding effort in a web application goes into the pages. The Struts Tags reduce effort by reducing code.

...

The Struts Tags also support validation and localization as a first-class features. So not only is there less code, but there is more utility.

Struts

...

Configuration in a

...

Nutshell

A web application uses a deployment descriptor to initialize resources like filters and listeners. The deployment descriptor is formatted as a XML document and named web.xml. Likewise, the framework uses a configuration file, named struts.xml, to initialize its own resources. These resources include action mappings, to direct input to server-side Action classes, and result types, to select output pages.

...

(lightbulb) The framework provides general-purpose defaults, so you can start using Struts right away, "out of the box". As needed, you can override any of our defaults in your application's configuration.

Struts Paradigm in a Nutshell

Apache Struts 2 helps you create an extensible development environment for your application, based on industry standards and proven design patterns.

Struts is a Model View Controller framework. Struts provides Controller and View components, and integrates with other technologies to provide the Model. The framework's Controller acts as a bridge between the application's Model and the web View.

To make it easier to present dynamic data, the framework includes its own library of markup tags. The tags interact with the framework's validation and internationalization features, to ensure that input is correct and output is localized. The tag library can be used with JSP, FreeMarker, or Velocity.

When a request is received, the Controller invokes an Action class. The Action class examines or updates the application's state by consulting the Model (or, preferably, an interface representing the Model). To transfer data between the Model and the View, properties can be placed on the Action class, or on a plain old JavaBean.

Most often, the Model is represented as a graph of JavaBean objects. The Model should do the "heavy lifting", and the Action will act as a "traffic cop" or adapter. The framework provides sophisticated, automatic type conversion to simplify transfering data between rich domain objects and text-only HTTP requests.

Struts is extensible. Very extensible. Every class deployed by the framework is based on an interface. We provide all the base classes an application may ever need, but if we missed something, it's easy to add your own. We provide the general-purpose framework, but you can still write your application your way.

Is Struts the best choice for every project?

No. If you need to write a very simple application, with a handful of pages, then you might consider a "Model 1" solution that uses only server pages.

...