Java Web Application Directory Structure Java Web Application Directory Structure

Java Web Application Directory Structure


The directory structure of Java web application deployment must meet the following requirements:


The web project can be deployed in any servlet container as long as the web application meets the above directory structure requirements when deployed.

In development, Tomcat is often used as the servlet server. The main directories of Tomcat are:

l bin directory: batch files and shell script files for starting and closing tomcat;

l conf directory: mainly stores configuration files, including server.xml (used to configure tomcat startup information, such as host, port, and virtual web application), web.xml, tomcat-user.xml;

l webapps directory: place web applications;

l logs directory: store log files;

l work directory: store the class file corresponding to jsp;

After the development is completed, as long as the web application meets the structural requirements of the web application directory, the web application can be placed in the webapps directory, and tomcat can be started to access the web application.

In the development stage, we do not want to place the web application in the webapps directory of tomcat. At this time, we can add the <context> subtag to the host node in the server.xml file of the tomcat configuration file, as follows

<ContextdocBase="/Users/ssl/jzt" path="/jzt" >

Where docBase specifies the location of the application directory, and path specifies the site name of the web application.

When deploying, an independent virtual host is often assigned to a web application, for example, the newly developed web application corresponds to the www.xyz.com domain name (note that the domain name must correspond to the real IP address; if not, you can add it to the local hosts file The domain name corresponds to the local address), then you need to configure the virtual host in the configuration file server.xml, as follows

<Host appBase="jzt"autoDeploy="true"name="www.xyz.com"unpackWARs="true"/>

appBase指定虚拟主机web应用存放的目录,该目录下ROOT作为默认启动应用(Context)。此外还可以指定Tomcat默认启动的是那个虚拟主机,配置如下

<Engine defaultHost="localhost"name="Catalina">

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325966225&siteId=291194637