Path of struts.xml and web.xml

徘徊边缘 提交于 2019-12-12 12:19:16

问题


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?


回答1:


  1. 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.

  2. 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.

  3. No.

  4. 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.

  5. 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.



来源:https://stackoverflow.com/questions/14971528/path-of-struts-xml-and-web-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!