When I'm going though struts2, I came through a typical question.
The question is that can I change the name of struts.xml
file to some other thing and make it work?
Asked
Active
Viewed 1,247 times
3

Roman C
- 49,761
- 33
- 66
- 176

Shiva Mothkuri
- 307
- 3
- 12
-
1I don't know if you can, but I also don't see why you'd want or need to. – Anthony Grist Apr 11 '14 at 14:20
-
@AnthonyGrist Just want to know whether that is possible or not as in hibernate. That's it. – Shiva Mothkuri Apr 13 '14 at 14:54
-
possible duplicate of [Changing struts.xml file name for a multi-module Maven web project](http://stackoverflow.com/questions/18955487/changing-struts-xml-file-name-for-a-multi-module-maven-web-project) – Roman C Jul 29 '15 at 11:09
2 Answers
4
You can do that using your web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>my-new-struts-config-file.xml,struts-plugin.xml,struts.xml</param-value>
</init-param>
</filter>
Also, if you use the struts.properties
you can do something like:
struts.configuration.files=my-new-struts-config-file.xml,struts-plugin.xml,struts.xml

Garis M Suero
- 7,974
- 7
- 45
- 68
-
I tried adding your code to web.xml.But, it isn't working. INFO: Parsing configuration file [struts.xml] Apr 13, 2014 8:14:41 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error SEVERE: Dispatcher initialization failed – Shiva Mothkuri Apr 13 '14 at 14:46
-
What did you use on the param-value? did you try using only the one file you are going to use?... also did you modify the properties file? – Garis M Suero Apr 14 '14 at 15:49
-1
You cannot change the name of struts.xml. You can, however, break up the Struts configuration among several configuration files which are named in strtus.xml.

hatellla
- 4,796
- 8
- 49
- 101