concept strut in category java

appears as: Struts
Struts 2 in Action

This is an excerpt from Manning's book Struts 2 in Action.

Struts 2 is a second-generation web application framework that implements the Model-View-Controller (MVC) design pattern. Struts 2 is built from the ground up on best practices and proven, community-accepted design patterns. This was also true for the first version of Struts. In fact, one of the primary goals of the first Struts was incorporating the MVC pattern from the desktop application world into a web application framework. The resulting pattern is occasionally called the Model 2 pattern. This was a critical step in the evolution of well-designed web applications, as it provided the infrastructure for easily achieving the MVC separation of concerns. This allowed developers with few resources for such architectural niceties to tap into a ready-made best practice solution. Struts 1 can claim responsibility for many of the better-designed web applications of the last 10 years.

At some point, the Struts community became aware of the limitations in the first framework. With such an active community, identifying the weak and inflexible points in the framework wasn’t hard to accomplish. Struts 2 takes advantage of the many lessons learned to present a cleaner implementation of MVC. At the same time, it introduces several new architectural features that make the framework cleaner and more flexible. These new features include interceptors for layering cross-cutting concerns away from action logic; annotation-based configuration to reduce or eliminate XML configuration; a powerful expression language, Object-Graph Navigation Language (OGNL), that transverses the entire framework; and a mini-MVC–based tag API that supports modifiable and reusable UI components. At this point, it’s impossible to do more than name drop. We’ll have plenty of time to fully explore each of these features. We need to start with a high-level overview of the framework. First, we’ll look at how Struts 2 implements MVC. Then, we’ll look at how the parts of the framework work together when processing a request.

Table 15.1. Recurring patterns found in struts mappings

Action method

Description

Next action method

add Prepare web page for save save
save Commit INSERT list
edit Prepare web page for update update
update Commit UPDATE list
destroy Prepare web page for remove remove
remove Commit DELETE list
show Prepare web page for detail display list
list Prepare web page for list display list
print Prepare web page for print list