Search code examples
struts2struts-configstruts2-config-browser

Struts2 - Difference between struts.xml and struts-plugin.xml?


I have confusion about these files in struts2. Normally struts.xml file the core which has configuration in struts1. So I also thought of using struts.xml file.

But in my project already they put struts2-config-browser-plugin.jar, it has struts-plugin.xml. Just searched in Google and found that struts-plugin.xml is enough to run struts application.

Now I'm adding the struts.xml file, the application is not working.

  1. Can I use both XML file in application?

  2. If I remove the struts2-config-browser-plugin.jar , what are the changes need to add in struts.xml file ?


Solution

  • There are three configuration files which are by default loaded by the framework (if they exist):

    • struts-default.xml - included in struts2-core.jar, contains all basic configuration of the framework
    • struts-plugin.xml - if plugin want to override some defaults or define its own settings (results, actions, etc)
    • struts.xml - contains user defined configuration, mostly actions, results and custom stacks of interceptors

    You should just use struts.xml and put all the configurations there.

    Some notes about struts-plugin.xml - http://struts.apache.org/development/2.x/docs/plugins.html