Javatpoint Logo
Javatpoint Logo

Struts 2 Tutorial: Multiple Configuration File Example

For a large application, it is better to use multiple configuration file that one so that it may be easy to manage the application.

We can create many configuration files but we need to define it in the struts.xml file. The includesub-element of struts is used to define the supported configuration file.

Example to create multiple configuration files

Let's see the simple example to define multiple configuration files.

1) Define entry of multiple configuration files in struts.xml

In this struts.xml file, we have defined 2 configuration files struts-first.xml file and struts-second.xml file.

The struts-first.xml file is located inside the first directory and struts-second.xml file is located inside the second directory.

struts.xml

2) Create configuration files

Let's create two configuration files that defines action with results.

struts-first.xml
struts-second.xml

Other Required Resources

To run this application, we need following resources:

  1. index.jsp
  2. Welcome.java
  3. 2 View Components

index.jsp

This jsp page creates two links.

index.jsp

Action class

It is the simple Action class containing only execute method.

Welcome.java

2 view components

The name of 2 view components are same i.e. welcome.jsp but both are located differently.

welcome.jsp

It is located inside the first directory under root.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA