As long as you create a dynamic Web Project in Eclipse, you can create a directory structure of a typical Java Web site based on the Creation wizard. Unless there is a special need, in most cases there is no need to modify this directory structure, this is also the default directory structure of the Web container, we only need to use directly. The general directory structure is as follows:
WebContent (site root directory)
|---meta-inf (meta-inf folder)
| |---MANIFEST. MF (MANIFEST. MF Config manifest file)
|---web-inf (web-inf folder)
| |---web.xml (site configuration Web.xml)
| |---lib (third-party library folder)
| | |---*.jar (the jar package required by the program)
| |---Classes (class file directory)
| |---... *.class (class file)
|---<userdir> (custom catalog)
| |---*.jsp,*.js,*.css,*images (custom resource file)
|---<userfiles> (custom resource file)
Under 1.WebRoot (webcontent) is the content published to the server.
2.meta-inf is the project itself related to some information, meta file information, usually by the development tool, the environment automatically generated.
3. File Web.xml: Completes the servlet's registration in the Web container. Web.xml is a deployment profile of a Web application that is used to parse and obtain Web application-related descriptions for a Web server.
Do not follow the sun's specifications to do the structure of application Web applications, Web containers can not find, for example, the XML file is wrong, the start Tomcat will be the error
4. Any resources that the client can access (*.html,*.jpg) must be in the same directory as Web-inf. The resources that are placed in the Web root directory can be accessed directly from the client through the URL address.
5. Avoid: All web-inf inside the file can not be directly accessed by the client (such as hidden information). The resources under the Web-inf directory are not visible to users, but are not limited to Web servers.
For example, under Web-inf index.htm, clients cannot access through http://yourserver/yourwebapp/WEB-INF/index.htm like the information in other folders. The Web-inf folder is prohibited from being accessed through a URL.
6. Java class files can be stored in the classes and Lib subdirectories of the Web-inf directory. At run time, the class loader of the servlet container loads the classes in the classes directory, and then loads the classes in the jar file (the Java class Library's packaged file) under the Lib directory, which is a collection of many class files. Therefore, if a class with the same name exists under two directories, the class in the classes directory has precedence.
Tomcat-Fixed directory structure |
/bin |
script files for starting and closing Tomat on Windows platforms and Linux platforms |
/conf |
A variety of configuration files that store Tomat servers, the most important of which are server.xml |
/server |
Contains 3 subdirectories: Classes,lib and WebApps |
/server/lib |
The jar files needed to store the Tomat server |
/server/webapps |
Storage of Tomat Two Web applications: Admin Application and Manager application |
/common/lib |
Jar applications that store Tomat servers and access to all Web applications |
/share/lib |
Store jar files that are accessible to all Web applications |
/logs |
Store Tomat log files |
/webapps |
When publishing a Web application, the Web application file is placed in this directory by default |
/work |
Tomcat puts the JSP-generated servlet in this directory |