Tomcat can access the project by using only the ip address and port, without the project name. tomcatip

Source: Internet
Author: User

Tomcat can access the project by using only the ip address and port, without the project name. tomcatip

Today, I found that the production tomcat project can only access the project using ip + port. I think it is strange that I cannot solve it. I tried to find out the reason.


Example:

Http: // 192.168.50.248: 8081/login.htm can directly enter the project login page

Http: // 192.168.50.248: 8081/project/login.htm can also enter the project login page


So I tried tomcat locally and found that if the project name is not added, the access would be 404,

After that, I added the project name and added the webpage to the project. However, the project name was lost and the response was 404 again.


Later, we found that it was originally caused by the default startup project of tomcat. If the default startup project of tomcat is configured, you can access the project without the project name.


The procedure is as follows:

 

1. Open the tomcat installation root directory, open service. xml under the conf directory, find the <Host> node, and add it under the node:

<Context docBase = "/home/tomcat/webapps/project" path = "" debug = "0" reloadable = "true"/>

Note: The Purple part is your project path. Because I put it under the webapps directory, it points to webapps.


2. Open the webapps directory under the tomcat directory, find the ROOT project, and change it to another name.


3. Restart Tomcat


After the restart is successful, you can directly access the project using the IP address and port in the browser.

Example: http: // localhost: 8081/login.htm



Finally, I still have a question. As a result, my initial path has a project name, so my next relative path request will also contain the project name.

It seems that the http: // 192.168.50.248: 8081/project/login.htm request can access the logon page, but why is the request successful? When return "/index,

Normally, http: // 192.168.50.248: 8081/project/index.htm should be returned.

However, the project name is also lost and the address is changed to http: // 192.168.50.248: 8081/index.htm. This is what I have a lot of questions about, I don't know where to configure it.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.