Struts 2 Tutorial and Examples with source code
Struts 2 is open source MVC framework in Java which very popular and used by
Java developers to develop applications. In this section we are giving your many
Struts 2 tutorial and examples for learn it from beginning.
Pre-requisites for learning Struts 2 Framework
Struts 2 framework is for creating user interface for web application and
following are pre-requisites for learning this framework.
Even if you don't know Spring framework you can start learning Struts 2
At the time of writing of this tutorial most latest Struts 2 framework as Apache
Struts 18.104.22.168 GA which was released on 7 March 2017. This version of Struts
was released with a fix for the bug which related to the file upload using
Jakarta Multipart parses. This fix removes the potential security vulnerability
of Possible Remote Code Execution during file upload.
Struts 2 framework can be integrated with modern AnguarJS, jQuery and other
front end frameworks to develop modern web applications.
Here are the best tutorials of Struts 2:
Beginning Struts 2.2.1
- Features of Struts 2.2.1
- Learn features of Struts 2 Framework
Understanding MVC design pattern
- MVC Design pattern is standard following in developing modern
- Developing Hello World application
- This tutorial will teach you to make your first Struts 2
Running and testing the example
- Learn How to run your first Struts 2 application?
Struts 2 hello world application using annotation
- Annotation is great way to write program quickly, in this
tutorial we are going to develop Struts 2 Hello world
application using annotation.
Running and testing the example
- In this section I will teach you to run the example program.
Advance Struts Action - For detail about the Advanced Struts 2
- Introduction to Action interface
- Introduction to the Action interface in Struts 2
Introduction to ModelDriven interface with example
- Learn about the model driven architecture
Example of ActionSupport class
- How to use ActionSupport class in your Struts 2 application?
Implementing Actions in Struts
2 - Example of implementing Actions in Struts 2
Chaining Actions in Struts
- What is chaining in Struts 2? Learn Action Chaining with
Configuring Actions in Struts application
- This section teaches you to configure the Actions in a Struts
Login Form Application
About Struts 2.2.1 Login application
- You can now learn to make the form based application and the
simple one is the login application.
Create JSP file
- This is the first step in creating login application in Struts
- Create Action class
- Action class is used to handle the request from user.
Add configuration in struts.xml file
- Let's see how to configure browser request, Action and JSP
page in our application?
Build and test application
- Finally application coding is ready and we are about to build
and run the application.
In this section you will learn various types of action results in Struts 2
with example code.
- Result interface in Struts 2.2.1
- Example and uses of result interface in Struts.
Chain Result Example
- How to chain result in Struts 2 application?
Dispatcher Result Example
- Example and explanation of result dispatcher in Struts 2.
Redirect Result Example
- Example of redirect result in Struts 2
Redirect Action Result Example
Stream Result example
- Introduction to XSL Result and its example
- Learn how to use PlainText Result
Tiles Result Example in Struts 2.2.1
- Introduction to PreResultListener
Pagination example in Struts 2.2.1
Validation in Struts 2.2.1 application
In this section you will learn how to validate the Struts 2 application using
validation framework as well as through custom code. Validating user input is
one of the major work for developers and they spend lot of time in writing code
for user input validation. These standard validators that comes with the Struts
framework that can be used.
Introduction to Validation Interceptor
- This section introduces you with the validation interceptor of
Struts 2 framework.
Client side Validation
- Understanding client side validation in Struts 2
Server side Validation
- Understanding serve side validation in Struts 2
- AJAX Validation
- Discussion about the Ajax validation in a Struts 2
- Using Field Validators
- Tutorial and example of using the field validator in Struts 2
Using Non Field Validators
Login form validation example
- How to validate login form in Struts 2? Learn it with using
various validation concepts of Struts 2
Struts 2.2.1 Tags
There are many different types of tags/tag library that comes with the Struts
2 framework. In this section we are learning to use these tag libraries to
create the UI Interface for the application.
- Type of Struts 2.2.1 tags
- This section explains you the various types of tags in Struts
Example of Generic Tags
Example of UI Tags
Example of Themes and Templates
- Example of Ajax Tags
- Example of OGNL
- How to use Checkboxes in Struts 2.2.1 applications
- Example of Iterator tag in Struts 2.2.1
- Learn how to format dates and numbers in Struts 2.2.1
- Skinning example in Struts 2.2.1
How to handle multiple Submit Buttons in your application
Ajax Application in Struts 2.2.1
In this section we are going to use Struts 2 framework to make simple Ajax
- Introduction to Ajax
Ajax support in Struts 2.2.1
Developing Simple Example
Interceptors in Struts 2.2.1
Learn to use different types of Interceptors in your application. You will
learn to use the file upload interceptor and ExecuteAndWait interceptors of
Struts 2 framework.
Introduction to AOP and Interceptor
Introduction to the Interceptor interface in Struts 2.2.1
How to configure interceptors in struts.xml
- How to configure Interceptor Orders in Struts application
Example of File Upload Interceptor
How to use ExecuteAndWait Interceptor
Type conversion is the concept of converting one type of data into another
type. Here you will learn about the type conversion in Struts 2.
Introduction to Type conversion in Struts
Type conversion example
Test-driven Development in Struts 2.2.1 application
Unit testing of the web based application is very import part and in this
section we are going to learn about the unit testing of Struts 2 application.
- JUnit -
JUnit is a Java based framework which is used for unit testing
Java application. In this section we are going to learn the
steps to unit test Struts 2 application.
- Using Spring mock objects
- Writing unit tests
- Test Actions
Database driven application in Struts 2.2.1
Learning of any framework is not complete without learning its integration
with database. Struts 2 is MVC framework for writing user interface in a web
application. In this section we will learn how to connect it to database and
access the data.
Adding database capability in Struts 2.2.1 application
Creating model classes
Writing action classes
Writing JSP files
Configuring in struts.xml file
Running and testing application
Finally we have few important examples you should learn to understand Struts
2 framework in a better way.
Struts PDF Generating Example
Struts 2 Interceptor Example
Struts Online Test application
Struts2.2.1 and hibernate integration application
Shopping Cart Application
Hibernate criteria example using struts2
After completing these Struts tutorial and examples you will be able to work
on the commercial projects. You will be able to develop applications for clients
using Struts 2 and any database access framework.
Visit Struts Tutorials
home page for finding more tutorials of Struts 2.