91-9990449935 0120-4256464 |
Struts 2 Tutorial: Multiple Configuration File ExampleFor 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 filesLet's see the simple example to define multiple configuration files. 1) Define entry of multiple configuration files in struts.xmlIn 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.xml2) Create configuration filesLet's create two configuration files that defines action with results. struts-first.xml struts-second.xmlOther Required ResourcesTo run this application, we need following resources:
index.jspThis jsp page creates two links. index.jspAction classIt is the simple Action class containing only execute method. Welcome.java2 view componentsThe name of 2 view components are same i.e. welcome.jsp but both are located differently. welcome.jspIt is located inside the first directory under root. welcome.jspIt is located inside the second directory under root. <h1>Welcome to second namespace</h1> |