Reputation: 3650
When I use eclipse to develop struts2. I found the struts.xml file can be put in src folder or WebContent\WEB-INF\classes. Both paths are ok.
What's the difference? what's better? Does different path affect the performance or other thing? Is there any other path for struts.xml file?
And the web.xml only can be put in WebContent\WEB-INF ? Or any other path for web.xml?
Upvotes: 4
Views: 6396
Reputation: 160181
From the web app's standpoint, there's no difference: struts.xml
is expected to be at the root of the classpath after deployment. How and when it gets there is irrelevant.
Putting the config file in the source directory is better, because you shouldn't need to manage the class directory itself. Tools like Maven move artifacts from a project's src/main/resources
directory to the classpath. It won't move an XML file from src/main/java
unless specifically configured to do so.
No.
You may override the default location. There's rarely a good reason to; so don't. If you're using multiple config files it's fine to put them in packages, but I'd leave them on the classpath.
That's a totally unrelated question, but it should stay in the default location, WEB-INF
. WebContent
is project-specific (Eclipse)–you'd need to configure the deployment/packaging process to find it.
Upvotes: 5