Tomcat web deployment project

Reprinted, the original link:  https://www.cnblogs.com/ysocean/p/6893446.html  invasion deleted

3, Tomcat directory structure

  

 

4, the first method of deployment projects (project directly into the webapps directory)

  1, will be prepared and compiled web project (note, if compiled, if it is eclipse, the project can be put in packages labeled as war), placed in the webapps

    

 

  2, start the tomcat server (startup.bat double-click apache-tomcat-6.0.16 \ bin directory, start the server)

    

 

      3, enter in your browser: http: // localhost: 8080 / project / file access

   

5, the second method deployment project (modify conf / server.xml file)

  ①, open the tomcat conf / server.xml, input items between <Host> </ Host> tag configuration information

1
<Context path= "/WebProject"  docBase= "D:/WebProject"  reloadable= "true"  />

  path: the path name when the browser visits

  docBase: Path WebRoot web project is located, note the path WebRoot path, not the project. In fact, the project is compiled

  reloadble: setting project changes, tomcat whether to re-load the project

  ②, double-click startup.bat, start tomcat server, and then enter the access project name in the browser's path

  

Note: If you have configured path = "/ xx", then the time of the visit is this:

  

 

6 , the third method of deployment projects (apache-tomcat-7.0.52 \ conf \ Catalina \ localhost)

  ①, into the apache-tomcat-7.0.52 \ conf \ Catalina \ localhost directory, create a new project name .xml file

  

 

 

  ②、在 那个新建的 xml 文件中,增加下面配置语句(和上面的是一样的,但是不需要 path 配置,加上也没什么用)

1
<Context  docBase= "D:/WebProject"  reloadable= "true"  />

  

 

 

  ③、在浏览器输入路径:localhost:8080/xml文件名/访问的文件名

   

 

 

总结:

①、第一种方法比较普通,但是我们需要将编译好的项目重新 copy 到 webapps 目录下,多出了两步操作

②、第二种方法直接在 server.xml 文件中配置,但是从 tomcat5.0版本开始后,server.xml 文件作为 tomcat 启动的主要配置文件,一旦 tomcat 启动后,便不会再读取这个文件,因此无法再 tomcat 服务启动后发布 web 项目

③、第三种方法是最好的,每个项目分开配置,tomcat 将以\conf\Catalina\localhost 目录下的 xml 文件的文件名作为 web 应用的上下文路径,而不再理会 <Context>中配置的 path 路径,因此在配置的时候,可以不写 path。

通常我们使用第三种方法

 

Guess you like

Origin www.cnblogs.com/x-x-736880382/p/11928949.html