The Tomcat server does not write the port number, does not write the project name to access the project, the virtual directory configuration

Source: Internet
Author: User
Tags tomcat server

One, do not write port.

This problem is bad, because the Tomcat default access port is 8080, and TCP/IP protocol default 80 port access, we see other sites do not write the port number is because they use the 80 port access, and 80 port because of the TCP/IP default port so do not write it. If you want to change it, you can do this in the Server.xml file in the Conf file in the Tomcat installation directory.

<connector connectiontimeout= "20000" port= "" protocol= "http/1.1" redirectport= "8443"/>

, the value of the port above Tomcat defaults to 8080, I changed it to 80 port here, it's that simple. After that you visit the project and no more ports are written.

Second, the virtual directory configuration.

Here take TOMCAT7 as an example. The virtual directory seems to me to exist to hide the real directory. The mapped real directory can be accessed indirectly through the virtual directory.

Open Tomcat7/conf/web.xml
Find <servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Change false to True at <param-value>
Open Server.xml again.
Add <context path= "/virtual directory Name" docbase= "D:\Tomcat 7.0\ folder name" before

After that, you will only be able to access your project name through the virtual directory name.

Third, the default project name (that is, do not write).

As we all know, under normal circumstances we access the name of the project in the Tomcat server is used (http://localhost:8080/xx/index.jsp) to access, where localhost refers to an IP address, 8080 refers to the port number () that accesses Tomcat, XX is the project name, and index.jsp is the Web page in the project.

But we often have many websites on the internet, we can directly enter the domain name to visit the Web site, here first the domain name equivalent to the ip+ Port bar. These sites and our own site to make a two-point difference, one is that we do not need to visit their own site as well as write the project name behind, today to share with you how it is done.

In fact, it is very simple, first complete the above virtual directory configuration (mainly SERVER.XM steps, the steps of Web. XML can be omitted), the value of path is set to "" On the line, in the future access to the project will not need to write the project name.

All right, the top three, when you're done, you can access the default Web page in your project by accessing localhost directly on your computer (don't tell me you don't know how to set the default access page for your project.) )

The Tomcat server does not write the port number, does not write the project name to access the project, the virtual directory configuration

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.