25 July, 2012

More struts-config.xml file in your Project

Is it possible to have multiple struts-config.xml in a single project ?

Answer:- YES

Yes,  its a new flavor for developers. In today's it is one of the most FAQ from most of the prominent IT/Software companies.

Yes, it is not too hard to implement struts-config.xml file more than one in your project. But , it may hazardous in case of proper settings.


Basically as per my experience multiple number of struts-config.xml file is not required always but in few cases when the project flow has many modules/sections and the development team want to maintain a separation layer for all module including struts fetures at that time we may require it.Here is the easy steps you can follow :-

Steps to Follow :-


 First few changes in WEB-INF/web.xml












Now, create 2 ( any number of xml file you can do) xml file as mentioned inside the web.xml file.
struts-config.xml 
struts-extra-config.xml
  

 struts-config.xml 

 










struts-extra-config.xml ( This is 2nd struts config file)










Now create 2 action file (Action Servlet) as per our example :-

MainactionAction.java
ExtrastrutsfileAction.java


MainactionAction.java














ExtrastrutsfileAction.java 














Finally create 3 jsp file for mapping forword .

index.jsp
main_struts_config_jsp.jsp
extra_struts_config_jsp.jsp

index.jsp


This file is first file from which we will send request to action.














Now your project structure like below :- 



Now run your project & Enjoy your multiple struts-config.xml file in a single project . Any doubt ping me.



No comments:

Post a Comment