struts.xml 和 web.xml 的路径 [英] Path of struts.xml and web.xml

查看:35
本文介绍了struts.xml 和 web.xml 的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用eclipse开发struts2的时候.我发现 struts.xml 文件可以放在 src 文件夹或 WebContent\WEB-INF\classes 中.两条路径都可以.

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.

有什么区别?什么更好?不同的路径是否会影响性能或其他事情?struts.xml 文件还有其他路径吗?

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?

而 web.xml 只能放在 WebContent\WEB-INF 中?或者 web.xml 的任何其他路径?

And the web.xml only can be put in WebContent\WEB-INF ? Or any other path for web.xml?

推荐答案

  1. 网络应用的角度来看,没有区别:struts.xml 预计在部署后位于类路径的根目录中.它如何以及何时到达是无关紧要的.

  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.

将配置文件放在源目录中更好,因为您不需要管理类目录本身.Maven 等工具将工件从项目的 src/main/resources 目录移动到类路径.它不会从 src/main/java 移动 XML 文件,除非经过专门配置.

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.

没有.

可以覆盖默认位置.很少有充分的理由这样做;所以不要.如果您使用多个配置文件,可以将它们放在包中,但我会将它们留在类路径中.

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.

这是一个完全不相关的问题,但它应该保留在默认位置,WEB-INF.WebContent 是特定于项目的 (Eclipse)——您需要配置部署/打包过程才能找到它.

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.

这篇关于struts.xml 和 web.xml 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆