Struts2 is popular and mature web application framework based on the
MVC design pattern. Struts2 is not just the next version of Struts 1,
but it is a complete rewrite of the Struts architecture.
পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Showing posts with label Struts 2 Tutorial. Show all posts
Showing posts with label Struts 2 Tutorial. Show all posts
Tuesday, January 24, 2017
Struts 2 - Environment Setup
Our first task is to get a minimal Struts 2 application running. This
chapter will guide you on how to prepare a development environment to
start your work with Struts 2. I assume that you already have have JDK
(5+), Tomcat and Eclipse installed on your machine.
Struts 2 - Architecture
From a high level, Struts2 is a pull-MVC (or MVC2) framework. The
Model-View-Controller pattern in Struts2 is realized with following five
core components:
Struts 2 - Hello World Example
As you learnt from the Struts 2 architecture, when you click on a
hyperlink or submit an HTML form in a Struts 2 web application, the
input is collected by the Controller which is sent to a Java class
called Actions. After the Action is executed, a Result selects a
resource to render the response.
Struts 2 - Configuration Files
This chapter will take you through basic configuration required for a
Struts 2 application. Here we will see what will be configured in few
important configuration files : web.xml, struts.xml, struts-config.xml and struts.properties
Struts 2 - Actions
Actions are the core of the Struts2 framework, as they are for any
MVC (Model View Controller) framework. Each URL is mapped to a specific
action, which provides the processing logic necessary to service the
request from the user.
Struts 2 - Interceptors
Interceptors are conceptually the same as servlet filters or the JDKs
Proxy class. Interceptors allow for crosscutting functionality to be
implemented separately from the action as well as the framework. You can
achieve the following using interceptors:
Struts 2 - Results & Result Types
As mentioned previously, the <results> tag plays the role of a view
in the Struts2 MVC framework. The action is responsible for executing
the business logic. The next step after executing the business logic is
to display the view using the <results> tag.
Struts 2 - Value Stack/OGNL
The Value Stack
The value stack is a set of several objects which keeps the following objects in the provided order:| SN | Objects & Description |
|---|---|
| 1 | Temporary Objects
There are various temporary objects which are created during
execution of a page. For example the current iteration value for a
collection being looped over in a JSP tag. |
Struts 2 - File Uploads
The Struts 2 framework provides built-in support for processing file
uploads using "Form-based File Upload in HTML". When a file is uploaded
it will typically be stored in a temporary directory and they should be
processed or moved by your Action class to a permanent directory to
ensure the data is not lost.
Struts 2 - Database Access
This chapter will teah you how to access a database using Struts 2 in
simple steps. Struts is a MVC framework and not a database framework
but it provides excellent support for JPA/Hibernate integration. We
shall look at the hibernate integration in a later chapter, but in this
chapter we shall use plain old JDBC to access the database.
Struts 2 - Sending Email
This chapter will teach you how you can send an email using your
Struts 2 application. For this exercise, you need to download and
install the mail.jar from JavaMail API 1.4.4 and place the mail.jar file in your WEB-INF\lib folder and then proceed to follow the standard steps of creating action, view and configuration files.
Struts 2 - Validations Framework
Now we will look into how Struts's validation framework. At Struts's
core, we have the validation framework that assists the application to
run the rules to perform validation before the action method is
executed.
Localization, internationalization (i18n)
Internationalization (i18n) is the process of planning and
implementing products and services so that they can easily be adapted to
specific local languages and cultures, a process called localization.
The internationalization process is sometimes called translation or
localization enablement.
Struts 2 - Type Conversion
Everything on a HTTP request is treated as a String by the
protocol. This includes numbers, booleans, integers, dates, decimals and
everything else. Every thing is a string according to HTTP.
Struts2 - Themes & Templates
Before starting actual tutorial for this chapter, let us look into few definition as given by http://struts.apache.org:
Struts 2 - Exception Handling
Struts provides an easier way to handle uncaught exception and
redirect users to a dedicated error page. You can easily configure
Struts to have different error pages for different execeptions.
Struts 2 - Annotations
As mentioned previously, Struts provides two forms of configuration. The traditional way is to use the struts.xml
file for all the configurations. We have seen so many examples of that
in the tutorail so far.
Struts 2 - Control Tags
The Struts 2 tags have a set of tags that make it easy to control the
flow of page execution. Following is the list of important Struts 2
Control Tags:
Struts 2 - Data Tags
The Struts 2 data tags are primarily used to manipulate the data displayed on a page. Listed below are the important data tags:
Subscribe to:
Posts (Atom)