What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache Struts 2 is an MVC web framework: it routes a browser request through controller components to an Action, lets that Action coordinate with your application’s model, then uses a mapped Result to produce the response. Interceptors wrap Action execution to handle reusable concerns such as validation, type conversion, and workflow. Knowing this sequence makes Struts configuration easier to read and maintain.

What MVC means in Struts 2

Apache describes Struts as a “Model View Controller framework.” Struts provides the controller and supports views, while your application supplies or integrates the model. An Action connects model state to the view; it should generally adapt the request and coordinate with model objects or services rather than contain the application’s heavy business logic. Apache Struts: What Is Struts?

  • Model: Your domain objects, services, and data-access layer. Struts does not prescribe a single persistence technology.
  • View: JSP, FreeMarker, Velocity, or another supported presentation technology. Struts tags can support forms, links, validation feedback, and localization.
  • Controller: The filter and dispatcher, mapping and invocation components, Actions, and configured interceptor stacks that coordinate request handling.

How a Struts request moves from browser to response

Consider a browser request for a mapped resource such as /mypage.action. The servlet container and Struts components process it in stages; the Result chosen for the Action determines how the response is produced. Apache Struts: How Struts 2 Works

  1. The servlet filter chain receives the request. The container passes it through configured filters to the Struts dispatcher.
  2. The dispatcher maps the request. The ActionMapper determines whether and how the request corresponds to a Struts Action.
  3. An ActionProxy and ActionInvocation are created. The proxy uses framework configuration—commonly struts.xml—to identify the Action and its invocation context.
  4. Interceptors run before the Action. The configured stack can convert request values, populate objects, validate input, or apply other shared behavior.
  5. The Action interacts with the model. It can call services or work with domain objects, then returns a result code indicating the next outcome.
  6. A mapped Result produces the response. A result can render a JSP, FreeMarker template, or another representation such as HTML, an image, or a PDF.
  7. Interceptor after-phases run in reverse order. The response then returns through the configured web filters to the client.

What Actions, Results, and Interceptors do

Actions coordinate a use case

An Action is the request-handling component for a mapped operation. It receives data made available by the framework, calls the relevant model or service, and returns a result name. Keep business rules in the model or service layer where practical so the Action remains an adapter between the web request and application behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Results map outcomes to responses

A Result associates an Action’s returned result code with a response behavior. For example, a success outcome might render a template, while another outcome may select a different view or response type. The result mapping keeps the Action’s outcome separate from the mechanics of rendering.

Interceptors wrap execution

Interceptors run around Action execution and let an application share solutions to recurring request concerns. Depending on the configured stack, they can support validation, type conversion, object population, upload handling, workflow, and duplicate-submit protection. Their order matters: an interceptor may prepare data for a later one, or short-circuit processing before the Action runs. Apache Struts: Interceptors

How to configure a Struts MVC application

Struts processes requests using three core types—interceptors, Actions, and Results—and supports configuration with XML or annotations. In a common XML-based application, struts.xml organizes packages, namespaces, Action mappings, interceptor references, and Result mappings; web.xml participates in servlet-filter configuration. Apache Struts Core Developers Guide

  • Package: Groups related configuration and can inherit shared settings.
  • Namespace: Helps organize URL mappings.
  • Action mapping: Connects a request path to an Action.
  • Interceptor stack: Defines which interceptors run and in what order.
  • Result mapping: Connects the Action’s returned outcome to a view or other response behavior.

Annotations are another configuration option, but the exact mapping and setup depend on the application and Struts version. Keep a mapping’s Action, interceptor behavior, and possible Results understandable as one request path; when debugging, check the URL mapping and namespace first, then the selected stack and result mapping.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical learning sequence

The official getting-started path covers the main concepts in an order that builds from a working application toward reusable behavior and testing. Apache Struts: Getting Started

  1. Create a Struts web application and confirm that a request reaches it.
  2. Write an Action and map it to a request.
  3. Process a form, then add form validation and handle messages or exceptions.
  4. Use form and control tags; learn wildcard method selection when you need it.
  5. Introduce interceptors and annotations, and explore Spring integration if the application uses it.
  6. Write unit tests, then study session handling and the Preparable interface where they fit your design.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to compare Struts with another Java web framework

There is no single architecture feature that determines which framework is a better fit. Compare the same application needs across each option: request routing, XML versus annotation configuration, middleware or interceptor composition, view support, validation and conversion behavior, testing approach, and integration with your model and dependency-injection stack. The cited Struts documentation describes its own capabilities; it does not establish a current performance or market-share comparison with other frameworks.

Quick Recap

Bestseller No. 4
Practical Apache Struts 2 Web 2.0 Projects
Practical Apache Struts 2 Web 2.0 Projects
Used Book in Good Condition
$38.58
SaleBestseller No. 5
Rank #4

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.