Struts Multi Configuration

Struts allows to create struts multi configuration xml files and include same in struts.xml file using <include file=””> tag.

1. Below is the folder structure we will be following as part of current implementation. 

2. Lets create user-struts.xml file inside src folder having unique name and namespace as shown in below screenshot.

3. Lets create one more address-struts.xml inside src folder having unique name and namespace as shown in below screenshot.

4. include both the struts config xml files inside main struts.xml file as show below. 

Note: struts.xml file can not have duplicate namespace. It will load and pick the first included at first position in struts.xml incase of duplicate namespace.

5. Create UserAction.java and AdressAction.java class file with below content.

6. As discussed earlier, namespace update will require to create folder with the same name of namespace as user-pack and address-pack.

OUTPUT:

http://localhost:8081/struts-demo/user-pack/user.action

http://localhost:8081/struts-demo/address-pack/address.action

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan