Sunday, March 24, 2013

Can we have multiple struts config file in struts?

Hi..,

  I have little knowledge about the struts. One of the main component of struts is struts-config.xml file which contains all the routing and configuration information for the struts application.

 I have aware about how to use the struts config just like all other java developers put all the struts related stuff(action,form,message resource etc.) into a single struts config file.

 One of my friend asked me once ,can we use multiple struts config file?? I never thought about this. Actually i do not know the answer but I said "yeah,i think we can use it. but i never used it". Then i got to know from the google.

Yes, We can have mulitple configuration file in one application. we can use it the following way.

 <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>
        org.apache.struts.action.ActionServlet
    </servlet-class>
    <init-param>
        <param-name>config</param-name>
        <param-value>
         /WEB-INF/struts-config-1.xml, /WEB-INF/struts-config-2.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

No comments:

Post a Comment