# Web project deployment to Tomcat method summaryA: The final release structure of the Web project is: The project is named EnvProjectstructure in Eclipse: Eclipse Export War Package: env for Upper directory Text description:Env meta-inf web-inf lib calsses web.xml< c21> two: web. XML Configuration<?xml version= "1.0" encoding= "UTF-8"?><web-app xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns= "http://java.sun.com/ Xml/ns/javaee"xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ Ns/javaee/web-app_3_0.xsd"id=" webapp_id "version=" 3.0 "> <display-name>T</display-name> <servlet> <servlet-name>Hello</ servlet-name > <servlet-class>com.tomatoman.env.EnvServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</ Servlet-name> <url-pattern>/hello</ url-pattern > </servlet-mapping> ........ </web-app> third, the project deployment methodMethod 1:put the project war package directly into the tomcat/webapps/directory and start Tomcat access. Note: The WebApps will be automatically extracted by Tomcat when it is accessed by the war package, so you can put the war package directly under Tomcat's WebApps. access mode: According to the configuration of Web. XML,Http://localhost:8080/Env/hello where Env is the name of the project when the Web project was created, and Hello is the servlet-mapping configured for XML.Method 2:Modify configuration file Tomcat/conf/server.xml, Server.xml <Host></ added in Host> < Context path = " " DocBase = "/users/gzq/documents/web/env" debug = 0 " reloadable = " True " /> among them,Top level directory of Docbase:web-infpath: virtual path,Access: Based on Web. XML and Context configuration,Http://localhost:8080/hello if the virtual path of the context is haha : <Context Path ="/haha" DocBase ="/users/gzq/documents/web/env" Debug ="0" reloadable ="true" />The access method is: Http://localhost:8080/haha/hello so the virtual path path is the ultimate way to access your project .Note:1,war Package is not placed under WebApps, Tomcat will not be automatically decompressed, so you need to unzip it well, the first level after the decompression directory configuration to Docbase can be2, if the war is under WebApps, you can not modify the Server.xml direct access, but if you still want to configure, or modify the access path, such as the direct access to the domain name, you can configure this, do not need to extract the war< Context path = " " DocBase = "/env" debug = 0 " reloadable = True " /> Method 3:In the conf directory, create a new XML file under the directory Catalina\localhost (note the case of the directory here), any name Zeze.xml (but the XML file name must match the name of the internal context virtual path path) , the Zeze.xml code is as follows. <context path= "Zeze" docbase= "/users/gzq/documents/web/env" debug= "0" privileged= "true"/>Access Path: Based on the configuration of Web. XML and Zeze.xml:Http://localhost:8080/zeze/hello Note:The XML file name added under the 1,catalina\localhost directory must be identical to the name of the internal context virtual path path, otherwise access error occurs. Five, note:Deleting a web app also deletes the corresponding context in the corresponding folder and Server.xml under WebApps, and also deletes the corresponding XML file in the Tomcat Conf\catalina\localhost directory. Otherwise Tomcat will still go to configure and load ... Summary:1, it can be considered that the first configuration (directly in the non-decompression of the war package into the WebApps directory), Tomcat will start automatically in memory for Server.xml <Host ></Host> in Configuration< Context path = "/env" docbase = /env " debug = " 0" reloadable < Span class= "token punctuation" >= " true /> where Env creates a project name for the Web project in Eclipse, and also the first level directory after the war package decompression2, the second and the third way to configure the more free, you can freely customize the path path, if not configured, you can use the domain name directly to access the servlet,3, if the second and third way of configuration, that is, path is empty < Context path = " " DocBase = "/users/gzq/documents/web/env" debug = 0 " reloadable = " True " /> Add this line of configuration to the project's Web. XML, <servlet-mapping> <servlet-name>Hello</ Servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> You can access the servlet directly by using the domain name:http://localhost:8080/
Tomcat deployment Web project Common ways