• October 3, 2014
  • Struts2
  • Comments Off on Struts 2 Configuration Files

Struts 2 Configuration Files

Struts.xml file:

The struts.xml is the core configuration file for struts framework. The struts.xml is used to initialize the resources like Interceptors, Action classes and Results.


   <package name="packageName" extends="struts-default">
      <action name="actionName" class="actionClass" method="methodName">
            <result name="success">/HelloWorld.jsp</result>
      //more actions.
   //more packages.

Commonly used attributes:

1. package attribute: It is used for modularization. You can divide configuration into multiple modules.

2. action attribute: It is a sub-attribute of the package attribute. It represents an action.

3. result attribute: It is a sub-attribute of the action attribute. It is used to control the flow after an action is executed.


The web.xml is known as deployment descriptor. It is used for providing entry point in any web application. In struts 2 we have to define FilterDispatcher class entry in web.xml.

web.xml file example:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 

Next Topic: Action in struts 2.
Previous Topic: Struts 2 Architecture.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.


Comments are closed.