Tomcat configures the project path in the conf/Catalina/localhost directory

Configure the project path in the conf/Catalina/localhost directory of tomcat, and the tomcat startup will load the project directly according to the configuration. 

If your project name is: mypro, then your file is named: mypro.xml. It can also be written as ROOT.xml, which can be accessed directly without writing the project name when accessing. 
A sentence in the file: <Context docBase="D:\Workspaces\mypro\WebRoot" path="/mypro" reloadable="true"/> 

docBase is the project path and path is the project name.

 

Several ways to deploy web programs in Tomcat

 

Reprinted from: http://qsfwy.iteye.com/blog/466461

There are two ways to deploy Java web applications in Tomcat: static deployment and dynamic deployment. In the following $CATALINA_HOME refers to the Tomcat root directory
1. Static deployment 
     Static deployment means that we deploy our program before the server starts, and our Web application can only be accessed after the server starts. The following 3 ways can be deployed: 
    1. Copy your WAR file or your web application folder to $CATALINA_HOME\webapps, and then start the server. This way is simpler, but the web application must be in the webapps directory. The access address is as follows: 
http://localhost:8080/project name/ 
   2. In this way, you can deploy directly in F:\ without copying the PetWeb directory to webapps. The method is as follows, change the $CATALINA_HOME\conf\server.xml file, add the <Context> tag in the <host> tag, the content is as follows:

<Context docBase="F:/PetWeb" reloadable="false" path="/Pet"/> 
where reloadable="false" means that the server will not automatically load when the content in the application changes, this attribute is in the development phase Usually set to true, which is convenient for development, and should be set to false in the release stage to improve the access speed of the application.

docBase is a path, you can use an absolute path, you can also use a relative path, the relative path is relative to webapps. The value of the path attribute is the root address when accessing. The access address is as follows: http://localhost:8080/Pet/ 
    3. This method is similar to the second method, but instead of adding the Context tag in the Server.xml file, it is in $CATALINA_HOME\conf\Catalina\localhost Add an xml file , such as Pet.xml, with the following content: 
<Context docBase="F:/PetWeb" reloadable="false" /> You may find that it is similar to the second method, but the path attribute is missing, this method server Will use the name of the .xml as the value of the path attribute. The access address is as follows: http://localhost:8080/Pet/ 

Second, dynamic deployment 
    Dynamic deployment means that the web application can be deployed after the server is started without restarting the server. The manager.war file provided by the server is used for dynamic deployment. If the file does not exist under $CATALINA_HOME\webapps\, you must download tomcat again, otherwise the following functions cannot be completed. To use this management program, you must first edit the $CATALINA_HOME\conf\tomcat-users.xml file, 
and the tomcat-users.xml file mentioned above, the content of this file is not dependent on any web application, so in any It can be used in a web program. If these users and roles only work for your application, then you can place them in your own application, such as WEB-INF. Next, we will add tomcat-users last time The content in the .xml file is added to the myUser.xml file we created under WEB-INF. Note that this file should be the root directory of <tomcat-users>, as shown below: 
<tomcat-users> 
  <!- -Define roles--> 
  <role rolename="suozhangshi"/> 
  <role rolename="guahaoshi"/> 
  <role rolename="danganshi"/> 
  <!--Define users and add them to roles--> 
  <user username="gua1" password="gua1" roles="guahaoshi"/> 
  < 
  <user username="dang1" password="dang1" roles="danganshi"/> 
  <user username="dang2" password="dang2" roles="danganshi"/> 
  <user username="suo1" password="suo1" roles="suozhangshi"/> 
  <user username="suo2" password="suo2" roles="suozhangshi"/> 
</tomcat-users> 

    This file has been created, so how to tell Tomcat to load this file? We add the Context.xml file to the META-INF folder in your web application in the following way, so that when the application is deployed, the content of the file will be loaded, as follows: 
<Context > 
  <Realm className="org.apache.catalina.realm.MemoryRealm" 
         pathname="webapps/SecurityWeb/WEB-INF/myUsers.xml" /> 
</Context> 
    The className attribute in the Realm tag defines the use of the MemoryRealm class to load the xml file from pathname. . Also note that the pathname here is relative to the Tomcat root directory, so the file path above should start from webapps. Finally restart the server and then access your program, you should be able to see the same effect as last time.

Guess you like

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