After tomcat is installed, the default homepage is index. However, if you want to modify or add a default homepage, you can refer to the following method to solve the problem.
The tomcat Management page is accessed through ip: port. Other projects deployed to the webapps directory of tomcat will use the default level-2 site structure. You can modify the default tomcat homepage in the following ways, enable http: // localhost: 8080/after starting tomcat to directly access your own page or web project.
1. If you only need to modify the homepage content, add or modify in/webapps/ROOT/WEB-INF/web. xml:
The Code is as follows: |
Copy code |
<? Xml version = "1.0" encoding = "ISO-8859-1"?> <! -- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License "); You may not use this file before t in compliance with the License. You may obtain a copy of the License Http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software Distributed under the License is distributed on an "as is" BASIS, Without warranties or conditions of any kind, either express or implied. See the License for the specific language governing permissions and Limitations under the License. --> <Web-app xmlns = "http://java.sun.com/xml/ns/j2ee" Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" Xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" Version = "2.4"> <Servlet-mapping> <Servlet-name> default </servlet-name> <Url-pattern>/</url-pattern> </Servlet-mapping> <Welcome-file-list> <Welcome-file> index.html </welcome-file> <Welcome-file> index.htm </welcome-file> <Welcome-file> index. jsp </welcome-file> </Welcome-file-list> </Web-app> |
2. Modify the $ CATALINA_HOME/webapps/ROOT/index. jsp page.
2. Directly deploy the project to the ROOT directory:
Clear the original ROOT directory;
Publish your project to the ROOT directory;
The default homepage definition needs to be included in the publishing program/webapps/ROOT/WEB-INF/web. xml;
Restart tomcat.
3. tomcat server. xml configuration:
Add or modify the <Host> label:
The Code is as follows: |
Copy code |
<Context path = "" docBase = "../webapps/myWeb"/> |
4. Homepage jump:
Modify/webapps/ROOT/index.html and add the js script:
The Code is as follows: |
Copy code |
<Script language = "javascript"> Window. location. href = "http: //" + window. location. hostname + "/myProj "; </Script> |