Java Reference
In-Depth Information
Figure 4-2. Architecture of Struts 2
As you can see from Figure 4-2 , Struts 2 is also an MVC-based framework that implements the Front
Controller pattern. The sequence of events in Struts 2 framework is as follows:
1.
The request is mapped to the configuration metadata.
2.
The request passes through a stack of interceptors that provide
preprocessing and postprocessing for the request and cross-cutting features.
The Action and the method in the Action that provides the logic to process
this request is invoked.
3.
The Result is invoked to render the response.
4.
5.
The response is returned to the user.
The key elements of Struts 2 illustrated in Figure 4-2 are discussed next.
Action
Actions are the core of the action-oriented Struts 2 framework because they provide the necessary
logic for request processing. Actions are not required to implement any interface or extend any
class, and actions can be POJOs. Listing 4-1 illustrates the action called HelloWorldAction .
Listing 4-1. An Action as a POJO
public class HelloWorldAction{
//...
public String execute() {
return "success";
}
}
 
Search WWH ::




Custom Search