Struts 2
Struts 2
Introduction
Objective
• Web Applications in Java
• MVC
• Brief History
• Why Struts 2.x
• Components of Struts2.x.
• Writing First struts2.x Application
Web Application in Java
• What is Web Container.
• Role of Web Container.
• What is Web Component.
– What is Servlet.
– What is JSP.
– Directory Structure and role of web.xml.
MVC
• Split the request processing for the page the user sees
into processing logic and the presentation logic, letting
each part do what it does the best.
•Actions,
• Interceptors,
•View technologies
High Level Architecture
configuration of a Struts2 application
Configuration files
• web.xml
– configuration for the FilterDispatcher servlet filter.
• struts.properties
– customize the web application execution environment
• struts.xml
– configure the components for the web application
•When including files, order is important. The information from the included file will
be available from the point that the include tag is placed in the file. Hence, to use a
tag that is configured in another file, the include configuration must occur before it
is referenced.
•There are some that are included automatically. These are the “strutsdefault.
xml” and the “struts-plugin.xml” files. Both contains default configurations for
result types, interceptors, interceptor stacks, packages as well as configuration
information for the web application execution environment
Some Important Tags in struts.xml
• The Package Tag:
• The <package … /> tag is used to group together
configurations that share common attributes
such as interceptor stacks or URL namespaces.
Usually this consists of action configurations,
• It may include any type of configuration
information.
• It may also be useful to organizationally separate
functions, which may be further separated into
different configuration files.
Package tag attributes
• name – a developer provided unique name for this package
• extends – the name of a package that this package will extend; all
configuration information (including action configurations) from the
extended package will be available in the new package, under the new
namespace