Beruflich Dokumente
Kultur Dokumente
Framework with examples. Struts 2 is very elegant and flexible front ontroller framework based
on many standard tehnologies like !ava Filters" !ava #eans" Resoure#undles" $%& et.
Struts 2 Training! Get Trained Now!!!
1. Struts 2 Features
It is very extensible as eah lass of the framework is based on an Interfae and all the
base lasses are given an extra appliation and even you an add your own.
2. Struts 2 History
'pahe Struts is an open(soure framework that is used for developing !ava web
appliation. Originally developed by the programmer and author )raig R. %)lanahan
this was later taken over by the 'pahe Software Foundation in 2**2.
3. Struts 2 Architecture
Struts and webwork has +oined together to develop the Struts 2 Framework. Struts 2
Framework is very extensible and elegant for the development of enterprise web
appliation of any si,e. In this setion we are going to explain you the arhiteture of
Struts 2 Framework.
4. Why Struts 2
The new version Struts 2.* is a ombination of the Sturts ation framework and
-ebwork. 'ording to the Struts 2.*.. release announement" some key features are/
5. Struts 1.x Vs Struts 2.x
In the following setion" we are going to ompare the various features between the two
frameworks. Struts 2.x is very simple in omparison to the struts ..x" few of its
exelling features are/
6. 0ownloading and Installing Struts 2
In this setion we will download and install the Struts 2.* on the latest version of Tomat
ontainer. -e will first download tomat and onfigure it as our development server.
Struts 2 Hello World Alication
7. !reating the de"elo#ent directory Structure
In this setion we will reate diretory struture of our Struts 2 1ello -orld appliation
based on Struts 2 framework. Our Struts 2 1ello -orld appliation is your first step
towards developing appliations based on Struts 2 framework.
8. Writing $s% $a"a and !on&iguration &iles
In this setion we will write !S2" !ava and re3uired onfiguration files for our Struts 2
1ello -orld appliation. 4ow in struts 2 struts.x#l is used to onfigure the appliations.
-e will also deploy and test the appliation.
9. Struts 2 x#l con&iguration &ile
In this setion we will introdue you with the struts.xml file. This setion explains you
how best you an use the struts.xml file for you big pro+ets.
Struts 2 Actions
10. Struts 2 'tions 5xample
-hen a lient re3uest mathes the ation6s name" the framework uses the mapping from
struts.x#l file to proess the re3uest.
11. Struts 2 Actions 'ntroduction
-hen a lient re3uest mathes the ation6s name" the framework uses the mapping from
struts.x#l file to proess the re3uest. The mapping to an ation is usually generated by a
Struts Tag.
12. Struts 2 (edirect Action
In this setion" you will get familiar with struts 2 Rediret ation and learn to use it in the
struts 2 appliation.
Struts 2 )ogin Alication
13. *e"eloing )ogin Alication in Struts 2
In this setion we are going to develop login appliation based on Struts 2 Framework.
Our urrent login appliation does not validate the user against the database.
14. Adding Validation to Struts 2 )ogin Alication
In this setion we will write the ode to validate the login appliation. 'fter ompleting
this setion you will be able to write validations for your Struts 2 pro+ets.
15. (unning and testing alication
In this setion we will run the example on Tomat 7.* server and hek how it works.
16. !lient Side Validation in Struts 2 )ogin Alication
In this setion we will see how to write ode that will generate !ava Sript ode for lient
side validation. In the last setion we developed &ogin(validator.xml onfiguration file
for defining the server side validation.
17. Validations using Struts 2 Annotations
In this setion we are going to validate our login appliation using 'nnotations in 'tion
lass. Our urrent login appliation does not validate the user against the database.
+ore Struts Validator ,xa#les
8ser input validations are an integral part of any web appliation. -ith the release of
Struts 2" validation are now muh easy and robust. Struts 2 support '+ax based and even
server side validations.
18. )ogin-)ogout With Session
In this setion" we are going to develop a login9logout appliation with session. This
appliation heks the user authentiation. -henever you run" it takes a user id and a
password :#oth the user id and password is ;ad#in;< it displays the welome page" when
both fields are orretly filled.
19. !onnecting to +yS.) *ata/ase in Struts 2 0Struts 2 +yS.)1
In this setion" =ou will learn to onnet the +yS.) database with the struts 2
appliation.
20. (ich ,ditor ,xa#le
In this setion" you will learn how to reate pagination in struts 2.
21. Validate TextArea
In this setion" you will learn how to validate your text area in struts 2. ' text area
ontains . to 2>* haraters. It ann6t support ;null; value.
Struts 2 Tags
22. Struts Tags
In this setion we will introdue you with the tags provided along with Struts 2
framework. It is neessary to understand all the tags provided along with Struts 2
framework.
Struts 2 Tags ,xa#les
23. Struts 2 Tags ,xa#les 0Generic Tags1
Struts 2 tags tutorials and examples.
24. !ontrol Tags2'& - ,lse '& - ,lse
In this setion we are going to disuss the various ontrol tags : The )ontrol Tags are
used for flow ontrol suh as if" else and iterate.<.
25. Aend Tag 0!ontrol Tags1 ,xa#le
In this setion" we are going to desribe the append tag. The append tag is a generi tag
that is used to merge multiple iterators into one iterator.
26. Generator Tag 0!ontrol Tags1 ,xa#le
In this setion" we are going to desribe the generator tag. The generator tag is a generi
tag that is used to generate iterators based on different attri/utes passed.
27. Generator Tag 0!ontrol Tags1 3sing !ount Attri/utes
In this setion" we are going to desribe the generator tag using the count attributes.
28. Generator Tag 0!ontrol Tags1 3sing an 'terator with 'd Attri/utes
In this setion" we are going to desribe the generator tag using the id attributes.
29. 'terator Tag 0!ontrol Tags1 ,xa#le
In this setion" we are going to desribe the Iterator tag. Iterator tag is used to iterate over
a value. 'n iterable value an be either of/ 4a"a.util.!ollection or 4a"a.util.'terator.
30. +erge Tag 0!ontrol Tags1 ,xa#le
In this setion" we are going to desribe the merge tag. The merge tag is a generi tag that
is used to merge iterators. The suessive all to the merge iterator auses eah merge
iterator to have a hane to expose its elements" subse3uently next all allows the next
iterator to expose its element.
31. Su/set Tag 0!ontrol Tags1 ,xa#le
In this setion" we are going to desribe the subset tag. The subset tag is a generi tag
that takes an iterator and outputs a subset of it. It delegates to
org.apahe.struts2.util.SubsetIteratorFilter internally to perform the subset funtionality.
32. Su/set Tag 0!ontrol Tags1 ,xa#le 3sing !ount
In this setion" we are going to desribe the subset tag using the count parameter. The
ount parameter indiates the number of entries to be set in the resulting subset iterator.
33. Su/set Tag 0!ontrol Tags1 ,xa#le 3sing Start
In this setion" we are going to desribe the subset tag using the start parameter. The
start parameter is of integer type. It indiates the starting index :eg. first entry is *< of
entries in the soure :needed to make available as the first entry in the resulting subset
iterator<.
34. Action Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the ation tag. The ation tag is a generi tag that
is used to all ations diretly from a !S2 page by speifying the ation name and an
optional namespae.
35. 5ean Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the #ean Tag. The #ean tag is a generi tag that
is used to instantiates a lass that onfirms to the !ava#eans speifiation.
36. *ate Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the 0ate tag. The date tag allows to format a
0ate in a 3uik and easy way. 8ser an speify a custo# &or#at :eg. ;dd9%%9yyyy
hh/mm;<" an generate easy reada/le notations :like ;in 2 hours" .? minutes;<" or an
+ust fall bak on a rede&ined &or#at with key 6struts.date.format6 in the properties file.
37. 'nclude Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the inlude tag. The inlude tag is a generi tag
that is used to inlude a servlet6s output :result of servlet or a !S2 page< to the urrent
page.
38. 6ara# Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the param tag. The param tag is a generi tag that
is used to parameteri,e other tags. For example the inlude tag and bean tag. The
parameters an be added with or without a name as a key.
39. Set Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the Set tag. The set tag is a generi tag that is
used to assign a value to a variable in a speified sope.
40. Text Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the text tag. The text tag is a generi tag that is
used to render a I.@n text message.
41. 6roerty Tag 0*ata Tag1 ,xa#le
In this setion" we are going to desribe the property tag. The property tag is a generi tag
that is used to get the property of a value" whih will default to the top of the stak if
none is speified.
42. Struts 2 Tags 03' Tags1 ,xa#les
For# Tags ,xa#les
43. Auto !o#leter ,xa#le
In this setion" we are going to desribe the autoompleter tag. The autoompleter tag
always displays a dropdown list with the options that have at least a partial math with
entered text in the textbox. If the user liks on the dropdown button then all options
shown in the dropdown list.
44. !hec7/ox Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the hekbox tag. The hekbox tag is a 8I tag
that is used to render an 1T%& input element of type hekbox" populated by the
speified property from the AalueStak.
45. !hec7/oxlist Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the hekboxlist tag. The hekboxlist tag is a 8I
tag that reates a series of hekboxes from a list. Setup is like Bs/selet 9C or Bs/radio 9C"
but reates hekbox tags.
46. !o#/o/ox Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the ombobox tag. The ombo box is basially an
1T%& I428T of type text and 1T%& S5&5)T grouped together to give you a ombo
box funtionality.
47. *ateti#eic7er Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the datetimepiker tag. The datetimepiker tag is
a 8I tag that is used to render a date9time piker in a dropdown ontainer.
48. *ou/leselect Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the doubleselet tag. The doubleselet tag is a 8I
tag that renders two 1T%& selet elements with seond one hanging displayed values
depending on seleted entry of first one.
49. File Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the file tag. The file tag is a 8I tag that renders
an 1T%& file input element ahieved through browsing.
50. For# Tag ,xa#le
In this setion" we are going to desribe the form tag. The form tag is a 8I tag that
renders 1T%& an input form.
51. )a/el Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the label tag. The label tag is a 8I tag that is used
to render an 1T%& &'#5& that allows to output la/el8na#e type of ombinations that
has the same format treatment as the rest of 8I ontrols.
52. 9tiontrans&erselect Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the Optiontransferselet tag. The
Optiontransferselet tag is a 8I tag that reates an option transfer selet omponent.
53. 9tgrou Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the optgroup tag. The optgroup tag is a 8I tag
that reates an optgroup omponent whih needs to reside within a selet tag
<s:select>.
54. 6assword Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the password tag. The password tag is a 8I tag
that renders an 1T%& input tag of type password.
55. (adio Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the radio tag. The radio tag is a 8I tag that
renders a radio button input field.
56. (eset Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the reset tag. The reset tag is a 8I tag that is
used with the form tag to provide form resetting.
57. Select Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the selet tag. The selet tag is a 8I tag that is
used to render an 1T%& input tag of type selet.
58. Su/#it Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the submit tag. The submit tag is a 8I tag that is
used to render a submit button. The submit tag is used with the form tag to provide
asynhronous form submissions.
59. Textarea Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the textarea tag. The textarea tag is a 8I tag that
is used to render an 1T%& textarea.
60. Text&ield Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the textfield tag. The textfield tag is a 8I tag that
is used to render an 1T%& input field of type text.
61. 3downselect Tag 0For# Tag1 ,xa#le
In this setion" we are going to desribe the updownselet tag. The updownselet tag is a
8I tag that reates a selet omponent with buttons to move up and down the elements in
the selet omponent.
Non2For# 3' Tags
62. Actionerror and Action#essage Tags 0Non2For# 3' Tags1 ,xa#le
In this setion" we are going to desribe the actionerror and action#essage tags. The
ationerror tag is a 8I tag that renders ation errors :in the +sp pages.< if they exists while
the ationmessage tag renders ation messages if they exists.
63. Fielderror Tag 0Non2For# 3' Tags1 ,xa#le
In this setion" we are going to desribe the fielderror tags. The fielderror tag is a 8I tag
that renders field errors if they exists.
64. Ta//ed6anel 0A4ax Tag1 ,xa#le
In this setion" you will learn about the tabbed2anel tag. This is an '+ax omponent"
where eah tab is either a loal ontent or a remote ontent :refreshed eah time when
user selets that tab<.
65. tree and treenode 0A4ax Tag1 tags ,xa#le
In this setion" you will learn about the tree and treenode tags. These both work with the
'+ax support.
66. *i" 0A4ax Tag1 tag ,xa#le
In this setion" you will learn about the di" tag. The di" tag is an '+ax omponent that is
used with '+ax that refreshes the ontents of a partiular setion without refreshing the
entire page.
Struts 2 ,xa#les
67. Struts 2 *ate
In this setion we will disuss the date proessing funtionalities available in the Struts 2
Framework.
68. *ate For#at ,xa#les
In this tutorials you will learn about 0ate Format funtion in Struts 2. -e have provided
fully tested example ode to illustrate the onepts.
69. Struts 2 datepiker 5xample
In this setion we will show you how to develop datetimepiker in struts 2. Struts 2 uses
the do+o toolkit for reating date piker.
70. Struts 2 For#at ,xa#les
In this setion you will learn how to format 0ate and numbers in Struts 2 Framework.
Our Struts 2 Format 5xamples are very easy to grasp and you will learn these onepts in
very small time.
71. Struts 2 File 3load
In this setion you will learn how to write program in Struts 2 to upload the file on the
server. In this example we are also providing the ode to save the uploaded file in any
diretory on the server mahine.
Struts 2 (esources ,xa#les
72. Struts 2 (esources ,xa#les
The struts 2 resoures examples
73. Static 6ara#eter
In this section, we will develop a simple application to access the static parameters. We will use a
JavaBean to set and get the static parameters. Each static parameter has a value.
74. Accessing Session 9/4ect
In this setion" we will develop a simple appliation to aess the framework resoures
like the session ob+et" session ontext and the last aessed session time.
75. Access (e:uest and (esonse
In this setion" you will learn to develop an appliation that aesses the re3uest and
response ob+et in struts 2 appliation.
Struts 2 Tools
76. Struts 2 ,clise 6lugin
This page ontains the examples and the list of plugins that are available for Struts 2
0evelopment using 5lipse I05.
77. Struts 2 '*,
This page ontains the list of I05s available to ease the development of Struts 2
Framework based appliations. The I05 for Struts 2 will atually make the development
yle muh easier.
78. Struts 2 Alication
0eveloping user registration appliation based on Struts 2 Framework. This Struts 2
'ppliation is a simple user registration appliation that will help you to learn how to
develop real world appliations using Struts 2 Framework.
79. Struts 2 A4ax
In this setion we explain you '+ax based development in Struts 2. Struts 2 provides
built(in support for '+ax using 0o+o toolkit.
Struts 2 Features
The strut-2 framework is designed for the comi!ation of the entire
de"e!oment c#c!e inc!uding of $ui!ding% de"e!oing and maintaining the
who!e a!ication. &t is "er# e'tensi$!e as each c!ass of the framework is
$ased on an &nterface and a!! the $ase c!asses are gi"en an e'tra a!ication
and e"en #ou can add #our own. The $asic !atform re(uirements are )er"!et
*+& 2.4% ,)+ *+& 2.0 and ,a"a 5.
)ome of the genera! features of the current *ache )trut 2 framework are
gi"en $e!ow.
Architecture - .irst the we$ $rowser re(uest a resource for which the .i!ter
/isatcher decides the suita$!e action. Then the &ntercetors use the
re(uired functions and after that the *ction method e'ecutes a!! the functions
!ike storing and retrie"ing data from a data$ase. Then the resu!t can $e seen
on the outut of the $rowser in 0T12% +/.% images or an# other.
Tags - Tags in )trut 2 a!!ow creating d#namic we$ a!ications with !ess
num$er of coding. 3ot on!# these tags contain outut data $ut a!so ro"ide
st#!e sheet dri"en marku that in turn he!s in creating ages with !ess code.
0ere the tags a!so suort "a!idation and !oca!i4ation of coding that in turn
offer more uti!i4ation. The !ess num$er of codes a!so makes it eas# to read
and maintain.
+V! D The +odel View !ontroller in Strut 2 framework ats as a oordinator between
appliationEs model and web view. Its )ontroller and Aiew omponents an ome together with
other tehnology to develop the model. The framework has its library and markup tags to present
the data dynamially.
!on&iguration D 2rovides a deployment desriptor to initiali,e resoures in $%& format. The
initiali,ation takes plae simply by sanning all the lasses using !ava pakages or you an use
an appliation onfiguration file to ontrol the entire onfiguration. Its general(purpose defaults
allow using struts diretly Out of the box.
)onfiguration files are re(loadable that allows hanges without restarting a web ontainer.
9ther Features8
'll framework lasses are based on interfaes and ore interfaes are independent from
1TT2.
)hek boxes do not re3uire any kind of speial appliation for false values.
'ny lass an be used as an ation lass and one an input properties by using any
!ava#ean diretly to the ation lass.
Strut 2 ations are Spring friendly and so easy to Spring integration.
'!'$ theme enables to make the appliation more dynami.
2ortal and servlet deployment are easy due to automati portlet support without altering
ode.
The re3uest handling in every ation makes it easy to ustomi,e" when re3uired.
Struts 2 - History of Struts 2
*ache )truts is an oen-source framework that is used for de"e!oing ,a"a
we$ a!ication. 5rigina!!# de"e!oed $# the rogrammer and author 6raig 7.
1c6!anahan% this was !ater taken o"er $# the *ache )oftware .oundation in
2002. )truts ha"e ro"ided an e'ce!!ent framework for de"e!oing a!ication
easi!# $# organi4ing ,)+ and )er"!et $ased on 0T12 formats and ,a"a code.
)trut1 with a!! standard ,a"a techno!ogies and ackages of ,akarta assists to
create an e'tensi$!e de"e!oment en"ironment. 0owe"er% with the growing
demand of we$ a!ication% Strut 1 does not stand firm and needs to $e
changed with demand. This !eads to the creation of )trut2% which is more
de"e!oer friend!# with features !ike *8a'% raid de"e!oment and
e'tensi$i!it#.
)truts is a we!!-organi4ed framework $ased on MVC architecture. &n Model-
View-Controller Architecture% 1ode! stands for the $usiness or data$ase
code% 9iew reresents the age design code and the 6ontro!!er for
na"igationa! code. *!! these together makes )truts an essentia! framework for
$ui!ding ,a"a a!ications. :ut with the de"e!oment of new and !ightweight
196 $ased framworks !ike )ring% )tries and Taestr#% it $ecomes
necessar# to modif# the )truts framework. )o% the team of *ache )truts and
another ,2;; framework% WebWork of OpenSymphony 8oined hand together
to de"e!o an ad"anced framework with a!! ossi$!e de"e!oing features that
wi!! make it de"e!oer and user friend!#.
Strut2 contains the com$ined features of )truts Ti and <e$<ork 2 ro8ects
that ad"ocates higher !e"e! a!ication $# using the architecture of
<e$<ork2 with features inc!uding a !ugin framework% a new *+&% *8a' tags
etc. )o the )truts communities and the <e$<ork team $rought together
se"era! secia! features in <e$<ork2 to make it more ad"ance in the 5en
)ource wor!d. 2ater the name of <e$<ork2 has changed to )truts2. 0ence%
*ache )trut 2 is a d#namic% e'tensi$!e framework for a com!ete a!ication
de"e!oment from $ui!ding% de!o#ing and maintaining.
-eb-ork is a framework for web(appliation development that has been inluded in Struts
framework 2.* release. It has some uni3ue onepts and onstruts like its ompatibility of
working within existing -eb '2Is in !ava rather than trying to replae them ompletely. It has
been built speifially taking into aount the developerEs produtivity and ode simpliity.
Furthermore it is ompletely ontext dependent that provides a wrapper around $-ork. -hen
working on web appliations the web work provides a ontext that helps web developer in
speifi implementations.
-hile" $-ork provides a mehanism that is used for onfiguration and fatory implementation
management. This mehanism is dependenies in+et mehanism.
Struts 2 Architecture - Detail information on Struts 2 Architecture
Struts and webwork has +oined together to develop the Struts 2 Framework. Struts 2 Framework
is very extensible and elegant for the development of enterprise web appliation of any si,e. In
this setion we are going to explain you the arhiteture of Struts 2 Framework.
(e:uest )i&ecycle in Struts 2 alications
1. 3ser Sends re:uest8 8ser sends a re3uest to the server for some resoure.
2. Filter*isatcher deter#ines the aroriate action8 The Filter0ispather looks at the
re3uest and then determines the appropriate 'tion.
3. 'ntercetors are alied8 Intereptors onfigured for applying the ommon
funtionalities suh as workflow" validation" file upload et. are automatially applied to
the re3uest.
4. ,xecution o& Action8 Then the ation method is exeuted to perform the database related
operations like storing or retrieving data from the database.
5. 9utut rendering8 Then the Result renders the output.
6. (eturn o& (e:uest8 Then the re3uest returns through the intereptors in the reverse
order. The returning re3uest allows us to perform the lean(up or additional proessing.
7. *islay the result to user8 Finally the ontrol is returned to the servlet ontainer" whih
sends the output to the user browser.
'#age8 Struts 2 high le"el o"er"iew o& re:uest rocessing8
Struts 2 Architecture
Struts 2 is a very elegant and flexible front ontroller framework based on many standard
tehnologies like !ava Filters" !ava #eans" Resoure#undles" $%& et.
For the +odel" the framework an use any data aess tehnologies like !0#)" 5!#" 1ibernate
et and for the View" the framework an be integrated with !S2" !T&" !SF" !akarta Aeloity
5ngine" Templates" 20F" $S&T et.
,xcetion Handling8
The Struts 2 Framework allows us to define exeption handlers and ineptors.
,xcetion Handlers8
5xeption handlers allows us to define the exeption handling proedure on global and
loal basis. Framework athes the exeption and then displays the page of our hoie
with appropriate message and exeption details.
'ntercetors8
The Intereptors are used to speify the ;re3uest(proessing lifeyle; for an ation.
Intereptors are onfigured to apply the ommon funtionalities like workflow" validation
et.. to the re3uest.
Struts 2 Architecture
The following diagram depits the arhiteture of Struts 2 Framework and also shows the the
initial re3uest goes to the servlet ontainer suh as tomat" whih is then passed through standard
filer hain.
'#age8 Struts 2 Architecture
The filter hain inludes/
Action !ontext!lean3 &ilter/
The 'tion)ontext)lean8p filter is optional and it is useful when integration has to be
done with other tehnologies like Site%ash 2lugin.
Filter*isatcher8
4ext the Filter0ispath is alled" whih in turn uses the 'tion%apper to determine
whether to invoke an 'tion or not. If the ation is re3uired to be invoked" the
Filter0ispather delegates the ontrol to the Action6roxy.
Action6roxy8
The 'tion2roxy takes help from )onfiguration Files manager" whih is initiali,ed from
the struts.xml. Then the 'tion2roxy reates an Action'n"ocation% whih implements
the ommand pattern. The 'tionInvoation proess invokes the Intereptors :if
onfigured< and then invokes the ation. The the 'tionInvoation looks for proper
result. Then the result is exeuted" whih involves the rendering of !S2 or templates.
Then the Intereptors are exeuted again in reverse order. Finally the response returns
through the filters onfigured in web.xml file. If the 'tion)ontext)lean8p filter is
onfigured" the Filter0ispather does not lean the Thread&oal 'tion)ontext. If the
'tion)ontext)lean8p filter is not present then the Filter0ispather will leanup all the
Thread&oals present.
In this setion we have learnt about the 'rhiteture of Struts 2 Framework.
Why Struts 2
The new "ersion Struts 2.; is a co#/ination o& the Sturts action &ra#ewor7 and We/wor7.
According to the Struts 2.;.1 release announce#ent% so#e 7ey &eatures are8
Si#li&ied *esign ( 2rogramming the abstrat lasses instead of interfaes is one of
design problem of struts. framework that has been resolved in the struts 2 framework.
%ost of the Struts 2 lasses are based on interfaes and most of its ore interfaes are
1TT2 independent. Struts 2 'tion lasses are framework independent and are simplified
to look as simple 2O!Os. Framework omponents are tried to keep loosely oupled.
Si#li&ied Actions ( 'tions are simple 2O!Os. 'ny +ava lass with exeute:< method
an be used as an 'tion lass. 5ven we don6t need to implement interfaes always.
Inversion of )ontrol is introdued while developing the ation lasses. This make the
ations to be neutral to the underlying framework .
No #ore ActionFor#s ( 'tionForms feature is no more known to the struts2
framework. Simple !ava#ean flavored ations are used to put properties diretly. 4o need
to use all String properties.
Si#li&ied testa/ility ( Struts 2 'tions are 1TT2 independent and framework neutral.
This enables to test struts appliations very easily without resorting to mok ob+ets.
'ntelligent *e&aults ( %ost onfiguration elements have a default value whih an be set
aording to the need. 5ven there are xml(based default onfiguration files that an be
overridden aording to the need.
'#ro"ed results ( 8nlike 'tionForwards" Struts 2 Results provide flexibility to reate
multiple type of outputs and in atual it helps to prepare the response.
5etter Tag &eatures ( Struts 2 tags enables to add style sheet(driven markup apabilities"
so that we an reate onsistent pages with less ode. Struts 2 tags are more apable and
result oriented. Struts 2 tag markup an be altered by hanging an underlying stylesheet.
Individual tag markup an be hanged by editing a Free%arker template. #oth !S2 and
Free%arker tags are fully supported.
Annotations introduced / 'ppliations in struts 2 an use !ava > annotations as an
alternative to $%& and !ava properties onfiguration. 'nnotations minimi,e the use of
xml.
State&ul !hec7/oxes ( Struts 2 hekboxes do not re3uire speial handling for false
values.
.uic7Start ( %any hanges an be made on the fly without restarting a web ontainer.
custo#i<ing controller ( Struts . lets to ustomi,e the re3uest proessor per module"
Struts 2 lets to ustomi,e the re3uest handling per ation" if desired.
,asy Sring integration ( Struts 2 'tions are Spring(aware. !ust need to add Spring
beansF
,asy lugins ( Struts 2 extensions an be added by dropping in a !'R. 4o manual
onfiguration is re3uiredF
A$A= suort ( The '!'$ theme gives interative appliations a signifiant boost.
The framework provides a set of tags to help you a+axify your appliations" even on 0o+o.
The '!'$ features inlude/