- Struts2 - Annotations
- Struts2 - Exception Handling
- Struts2 - Themes/Templates
- Struts2 - Type Conversion
- Struts2 - Localization
- Struts2 - Validations
- Struts2 - Sending Email
- Struts2 - Database Access
- Struts2 - File Uploads
- Struts2 - Value Stack/OGNL
- Struts2 - Result Types
- Struts2 - Interceptors
- Struts2 - Actions
- Struts2 - Configuration
- Struts2 - Examples
- Struts2 - Architecture
- Struts2 - Environment Setup
- Struts2 - Overview
- Struts2 - Basic MVC Architecture
- Struts2 - Home
Struts 2 Tags
Struts 2 Integrations
Struts 2 Useful Resources
- Struts2 - Discussion
- Struts2 - Useful Resources
- Struts2 - Quick Guide
- Struts2 - Questions and Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Struts 2 - Architecture
From a high level, Struts2 is a pull-MVC (or MVC2) framework. The Model-ViewController pattern in Struts2 is implemented with the following five core components −
Actions
Interceptors
Value Stack / OGNL
Results / Result types
View technologies
Struts 2 is spghtly different from a traditional MVC framework, where the action takes the role of the model rather than the controller, although there is some overlap.
The above diagram depicts the Model, View and Controller to the Struts2 high level architecture. The controller is implemented with a Struts2 dispatch servlet filter as well as interceptors, this model is implemented with actions, and the view is a combination of result types and results. The value stack and OGNL provides common thread, pnking and enabpng integration between the other components.
Apart from the above components, there will be a lot of information that relates to configuration. Configuration for the web apppcation, as well as configuration for actions, interceptors, results, etc.
This is the architectural overview of the Struts 2 MVC pattern. We will go through each component in more detail in the subsequent chapters.
Request Life Cycle
Based on the above diagram, you can understand the work flow through user s request pfe cycle in Struts 2 as follows −
User sends a request to the server for requesting for some resource (i.e. pages).
The Filter Dispatcher looks at the request and then determines the appropriate Action.
Configured interceptor functionapties apppes such as vapdation, file upload etc.
Selected action is performed based on the requested operation.
Again, configured interceptors are appped to do any post-processing if required.
Finally, the result is prepared by the view and returns the result to the user.