在Eclipse中,我创建Dynamic Web Project时的文件夹结构是
[srikanth@hana Sample]$ ls -R
.:
build src WebContent
./build:
classes
./build/classes:
./src:
./WebContent:
index.html META-INF scripts WEB-INF
./WebContent/META-INF:
MANIFEST.MF
./WebContent/scripts:
jquery-1.7.1.js
./WebContent/WEB-INF:
lib web.xml
./WebContent/WEB-INF/lib:
如您所见,有这个 WebContent 目录,当我从 Eclipse 工作区复制目录结构并放入 Tomcat 的 webapps 目录时,它不起作用。但是,如果我将 WebContent 目录下的所有目录和文件移动到更高一级,它就可以正常工作。
这是应用程序下 Tomcat 的 webapps 目录中的文件夹结构:
[srikanth@hana Sample]$ ls -R
.:
build index.html META-INF scripts src WEB-INF
./build:
classes
./build/classes:
./META-INF:
MANIFEST.MF
./scripts:
jquery-1.7.1.js
./src:
./WEB-INF:
lib web.xml
./WEB-INF/lib:
所以,现在我可以转到 http://localhost:8080/Sample
并可以正确地转到 index.html
What am I doing wrong? Why didn't it work just copying the application from Eclipse to tomcat webapps directory directly? Why do I have to change the directory structure?
最佳答案
我有同样的问题,./WebContent/index.html 没有出现在 Eclipse 导出的 .war 中。在我使用 Kepler Eclipse 从我的旧系统重新创建一个工作项目到使用 Luna Eclipse 的新系统后,我的新 Eclipse 系统上发生了这种情况。
我通过转到 Project/Properties/Deployment Assembly 解决了这个问题。我发现旧的工作系统有这个规则,而我的新的非工作系统没有这个规则......
Source = /WebContent
Deploy Path = /
我通过按“添加...”并添加缺少的规则在新系统上更正了此问题。
关于tomcat中Eclipse WebContent目录部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9657724/