简体   繁体   中英

Java webapps - why is index.html displayed when visiting a webapps root directory?

Say you have a webapp named MyWebApp deployed on Tomcat in localhost. If you visit it with your browser like this:

localhost:8080/MyWebApp

then why is the index.html displayed (assuming there is an index.html in the .war file)?

Is there a configuration somewhere that says requests to /MyWebApp should be responded to by sending the index.html? Is it possible to change that configuration? Why isn't there a servlet that handles this request?

The index.html page is specified as welcome page in web.xml file .

Which looks like this:-

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

this is the reason why you see index.html as welcome page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM