How to modify the default tomcat Homepage

Source: Internet
Author: User

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>

Related Article

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.