Struts Configuration file
Struts framework uses a
centralized XML file based configuration. This allows us to configure most of
the application properties like actions, formbeans, I18N, data sources etc in
XML files rather than hard coding into java classes, which means that any changes
to these configurations can be made without modifying or recompiling java code
and the changes can be made by modifying a single file struts configuration
file. This even benefits the Java developers to concentrate on implementing the
business logic without needing to know about the overall system layout and
concentrating on the infrastructure logic configurations. In this section, we
will discuss the top level elements of struts configuration file like data
sources form beans gloal-exception, global-forwards, action-mappings,
controller, message-resources and plug-in. In this section, we will discussing
the other topics in this struts post. The root element of struts configuration
file is <struts-config> this element contains the following child
elements.
Element
Name
|
Description
|
Occurrence
|
Display-name
|
Contains short description of this module this is used in GUI tools
|
Optional
|
Description
|
Contains descriptive text of this module this is also for the use in
GUI tools
|
Optional
|
Form-beans
|
Encapsulates all the form bean definitions of this module, where each
of the form bean is defined using a formbean tag which is a child tag of this
element
|
Optional
|
Global-exceptions
|
This element describes a set of excetion handler declarations that
are in common for all the actions in this module. The <action> element
can override a global exception handler by configuring a local exception
handler for the same exception type.
|
Optional
|
Global-forwards
|
This element describes a set of forwards that are in common for all
the actions in this module. The <action> element can override a global
forward declaration by configuring a local forward declaration with the same
forward name.
|
Optional
|
Action-mapping
|
This element holds all the action declarations of this module, where
each of the action is configured using <action> tag
|
Optional
|
Controller
|
This element describes module runtie configuration details for this
module like buffer-size it has to use while processing file uploads, Local
scope, controller class etc
|
Optional
|
Message-resources
|
Describes the MessageResources object that defines the resource
bundle that struts has to use while looking up for locale specific messages
in this module
|
Optional and can appear for more than ones
|
Plug-in
|
This allows configuring additional plugins for this module.
|
Optional and can appear for more than ones
|
The above table describes the high – level elements of
struts configuration file and the child tags of these high-level tags are
describes in details in the next post.
Struts application has minimum one module and can be
configured to handle multiple modules and in such a case we need to write a
separate struts configuration file for each module with there respective
configurations. As we have discussed an overview of struts configuration file
and its top level elements we will continue our discussion on the other
elements of struts architecture next post describes about the RequestProcessor.
Post a Comment
Post a Comment