Change the configuration method for the site root and default pages in Tomcat

  • 2020-05-10 23:12:19
  • OfStack

1. The original default root directory of tomcat was http://localhost:8080. If you want to modify the root directory you access, you can do this:

Find server.xml (under conf) for tomcat, find:

<Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false"></Host>


in < /Host > Insert before:

<Context path="" docBase="D:/eclipse3.3/ofstack.com/tomcat/" debug="0"/>

Including D: / eclipse3. 3 / ofstack. com tomcat/is what I want to set the web root directory, and then restart the tomcat.


Visit http again: / / localhost: 8080, is a direct access to the D: / eclipse3. 3 / ofstack com tomcat/files in the directory.


2.tomcat web.xml (in the conf directory), found in this file


    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

This is the default tomcat 3 files, when you enter the specified path, tomcat will automatically find these 3 pages. If you want tomcat to automatically find your own page, for example main.jsp. The above information can be modified as follows:


    <welcome-file-list>
        <welcome-file>main.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
     
That's it.


Related articles: