This article will try to make the most detailed explanation of java web project directory structure, and try to make it easy to understand.
eclipse web project directory structure
- 03-springmvc-drien-xgq is the name of the project created, the name can easily create their own, provided that they meet naming rules.
- src and src_test which put the java source code, that is, you write java code, in order to manage here so that I can just put the original src into two, and became src src_test.
- Library System the JRE : Java SE refers to a set of common libraries, jar package is to establish a common Java project will use; for example, in my project, JRE System Library's contents are as follows:
-
Apache Tomcat v7.0 means that this project depends server (Tomcat) directory.
-
Web App Libraries is a project of his own import-dependent jar package, all the jar packages in the Web App Libraries can locally \ WebContent \ WEB-INF \ lib project name found. If you directly in the WEB-INF / lib folder, copy a jar package, refresh, automatically compiled into Web App Library in.
-
Referenced Libraries 是编译环境下使用的 jar 包, 所谓编译环境下使用的 jar 包, 就是说你在 Eclipse 中进行源文件的编写的时候, 所需要引用到的类都从 Referenced Libraries 这个集合中的 jar 包中拿。这里导入和配置 ja r包,都是为了让 web 工程能够在 eclipse 开发环境可以正常编译,不报错而已。
-
build:eclipse新建的 Dynamic web project 默认是将类编译在 build 文件夹下。可以在本地的项目名\build\classes 下查看。
-
WebContent:一般我们用 Eclipse 的时候创建一个 Web Project,就会生成 WebContent 文件夹,用 MyEclipse 的时候创建一个 Web Project,就会生成 WebRoot 文件夹,这两个文件夹作用一样只是名称不同而已。WebContent 用来存放 JSP,JS,CSS,图片等文件,是项目访问的默认路径,也是工程的发布文件夹,发布时会把该文件夹发布到 tomcat 的 webapps 里。
-
common:用来存放公用的 JSP,JS,CSS,图片等文件。
-
META-INF:存放一些 meta information 相关的文件的这么一个文件夹, 一般来说尽量不要自己手工放置文件到这个文件夹。
-
WEB-INF:WEB-INF 目录是一个专用区域, 容器不能把此目录中的内容提供给用户。这个目录下的文件只供容器使用,里面包含不应该由客户直接下载的资源。Web 容器要求在你的应用程序中必须有 WEB-INF 目录。WEB-INF 中包含着发布描述符(也就是 web.xml 文件), 一个 classes 目录和一个 lib目录, 以及其它内容。注意: 如果你的 Web 应用程序中没有包含这个目录, 它可能将无法工作 。
-
web.xml:发布描述符(deployment descriptors)是 J2EE Web 应用程序不可分割的一部分(也就是说是它的最小部分, 必不可缺的一部分)。它们在应用程序发布之后帮助管理 Web 应用程序的配置。
-
WEB-INF/classes 目录,编译后的 Java类,这个文件夹是可选的。有一些配置文件需要放到 WEB-INF 的 classes 文件夹下,所以,通常的做法是手动在工程的 WEB-INF 文件夹下建立 classes 文件夹。如果不在工程的 WEB-INF 下手动建立 classes,发布到 tomcat 时 tomcat 里的WEB-INF 中也会有 classes 文件夹。
-
WEB-INF/lib 目录,该目录中的 jar 包是运行时环境下使用的 jar 包, 所谓运行时环境下使用的 jar 包,就是说你在运行你的项目的时候所需要使用的 jar 包的集合。
-
index.jsp:首页页面
Tomcat 目录结构
一张图搞定:
原文链接:https://www.jianshu.com/p/91050dfcbe33