How to have 2 or more Struts config file

Some times when you work in group, you work on different modules of a single project so each module has its own struts config file…
Now when you want to combine all the modules to make a complete project than sometimes we face problem to merge multple struts config file into one.

So here is the Code how to have multiple struts config file in a project

In order to tell the framework about your different modules(different struts config file), we specify multiple ‘config’ initialization parameters in our Web.xml. we’ll still use ‘config’ to tell the ActionServlet about our “default” module, however, for each additional module, we will list an initialization parameter named “config /module “, where /module is the prefix for our module. For eg:-


<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/conf/struts-config1.xml</param-value>
</init-param>
<init-param>
<param-name>config/module1</param-name>
<param-value>/WEB-INF/conf/struts-config2.xml</param-value>
</init-param>

Here we have two modules. One happens to be the “default” module, identified by the param-name of “config”, and the other will be using the module prefix “/module1” based on the param-name it was given (“config/module1”).

Similarly we can write code for more than 2 Struts config file.

That’s it!!!

Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: