Last Updated on 01 August 2019   |   Print Email
Typically we use only struts.xml file to configure a small Struts2 application. For larger and more complex application with many modules, the struts.xml file becomes bulky, thus hard to maintain.So Struts provides an option to break the struts.xml file into multiple configuration files, using the <include> element in the struts.xml file. Here’s a quick example:
As we can see, this struts.xml file includes 4 other configuration file which each corresponds to a separate module of the application: common, admin, user and product. This would help to modularize the application in which each team/developer can work on a particular configuration file independently.According to Struts2 documentation, the included files must have same format as the struts.xml file (including the DOCTYPE declaration). Here are two examples for the Admin.xml and User.xml files above:Admin.xml:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.
Comments