Eclipse Dynamic Web Project如何组织文件?

Eclipse Dynamic Web Project how to organize files?

所以我正在学习 Web 应用程序开发,我对如何在 Eclipse 为动态 Web 应用程序提供的模板中组织我的文件感到有点困惑。

我应该将 HTML 页面放在 WebContent 中吗? JSP 和 servlet 源文件放在哪里?全球遵循什么公约?

这是eclipse提供的模板结构

将 HTML 和 JSP 页面放入 WebContent 目录。

Eclipse 帮助页面 referenced by android-weblineindia 指出 WebContent 是:

The mandatory location of all Web resources, including HTML, JSP, graphic files, and so on. If the files are not placed in this directory (or in a subdirectory structure under this directory), the files will not be available when the application is executed on a server. The Web content folder represents the contents of the WAR file that will be deployed to the server. Any files not under the Web content folder are considered development-time resources (for example, .java files, .sql files, and .mif files), and are not deployed when the project is unit tested or published.

所以CSS浏览器需要的文件和JS文件也要放在这里

将 java 个源文件(包括 servlet 源文件)放在 src 目录中。同一个帮助页面为源目录声明了这一点(尽管它建议它被称为 JavaSource,这在文档中看起来像一个错误):

Contains the project's Java source code for classes, beans, and servlets. When these resources are added to a Web project, they are automatically compiled and the generated files are added to the WEB-INF/classes directory. The contents of the source directory are not packaged in WAR files unless an option is specified when a WAR file is created.

如果您查看项目 Properties -> Deployment Assembly,您应该会看到从 src 编译的文件被部署到 WEB-INF/classes,而 WebContent 中的文件被部署到WAR 文件