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