- Developed by Craig MacClanhan ( in 2000)and donated to apache software foundation, initial version is developed in 2001.Current stable version of struts 2.3.3,developed in May 2012.
- It is a open source java framework for developing the web-application.
- It is combination of struts1 and webwork framework
- It inbuilt follow the MVC2 design pattern .
- Reduce the cross-cutting concern in web-application.
- It is invasive by nature means force programmer to inherit predefine classes/interfaces.
Required Jar(library file):
Requirement of Struts:
- Action Class
- Request Page
- Configuration File
- Action Class : have a execute method that content logic for struts programming.
- Configuration File: to configure the requirement struts use two xml file web.xml and struts.xml.
- Web.xml configure the framework define things like controller(filter) ,listener , welcomepage ,and url-pattern.
- Struts.xml: it configure the user define classes ,result pages etc.
Some Interfaces/Classes of Struts:
- Action Interface
- ActionSupport Class
- Interceptor Interface
- ModelDriven Interface
- Validatable Interface
- Preparable Interface
- Aware Interfaces
- ValueStack Interface
- ActionContext Interface
- ActionInnvocation class
Features of Struts:
- Provide inbuilt support for validation means doesn’t have implement it explicitly.
- Provide support for Ajax that improve the presentational view.
- Provide support for i18n(internationalization).
- MVC design pattern make it independent, reusable ,sharable and secure.
- Provide different type of result type for generating the view.
- It provide their own tag library for creating the request page.
- It allow implement more than one method as execute() and also makes execute() independent by declaring it non-parameterized.
Flow of Struts:
- First of all request goes to web-container(Tomcat in Apache server) .
- Web container loads web.xml and verifies the url-patterns , if url matches with request web-container transfer the request to Filter Dispatcher(Controller of struts).
- Controller hands the request to proxy class(ActionProxy) which is responsible to apply pre and post services to business logic.
- Proxy class contacts ConfiguraionManager class, to know the requested Action and the needed services for fulfilling the request.
- ConfigurationManager class loads struts.xml and sends the required information back to proxy class.
- Proxy class delegates the request along with its information to ActionInvocation.
- ActionInvocation line-up the interceptors added to an Action .
- ActionInvocation finally receives result produced by an action class.
- ActionProxy transfers the result back to FilterDispatcher.
- FilterDispatcher selects an appropriate view, based on the result.
- Finally FilterDispatcher uses result type for forwarding response(by-default RequestDispatcher ) back to the client.
- It is used to create the user define Action class.
- It have a method execute() and five predfine string constant.
- String constant are……
- It is also used to create user define Action class .
- Ii itself inherit 5 interface from struts-api Action ,Validatable ,ValidationAware , TextProvider , and LocaleProvider.
- It contents the property of all inherited class that make it more versatile for creating Action.
- It provide auto-validation for the field on the basis of datatype.
- It is used to create the user define interceptors.
- It have three methods…
- Xml-Configuration tag:
Used of Interceptors:
- Interceptor is an object that is invoked at the pre-processing and post-processing of a request. In Struts 2, interceptor is used to perform operations such as validation, exception handling, internationalization,file-uploading, displaying intermediate result etc.
- It is plug-gable If we need to remove any concern such as validation, exception handling, logging etc. from the application, we don't need to redeploy the application. We only need to remove the entry of interceptors from the struts.xml file.
- Interceptor in lineup-ed for execution by ActionInvocation.
- It reduce the cross-cutting concerns in web-application.
Reach us At: - 0120-4029000 / 24 / 25 / 27 / 29 Mobile: 9953584548
Write us at: - Smruti@apextgi.com and email@example.com