zoukankan      html  css  js  c++  java
  • 关于web.xml中的<welcome-file-list>中的默认首页文件

    先看我的配置文件: 
    Java代码  收藏代码
    1. <welcome-file-list>  
    2.     <welcome-file>index.html</welcome-file>  
    3. </welcome-file-list>  


    很普通,没有任何问题。但是访问http://localhost/的时候,不会去找index.html,出现404错误。 

    如果手工输入http://localhost/index.html又可以访问。 


    问题出在哪呢?整了好几天,今天总算搞明白了: 
    我的index.html不是个物理存在的文件,是个struts2的action,index是action的name 

    Tomcat不是在请求http://localhost的时候去找能不能访问到index.html 
    而是在容器启动加载的时候,就去webapp的主目录找index.html这个物理文件。如果找不到,你在访问的时候,就返回404给你。 

    知道Tomcat的这个原理,问题的解决也就很简单了。 
    设置 在WEB-INF/web.xml
     <welcome-file-list>
        <welcome-file>index.html</welcome-file>

        </welcome-file-list>

    最好是在tomcat conf/web.xml 也配置中也配置一下。

  • 相关阅读:
    data guard switchover切换异常
    oracle dataguard
    建立信任关系
    sqlplus 打印很乱,而且很短就换行
    老友记英语
    每天读一遍
    extern的用法
    linux信号处理
    http server v0.1_http_parse.c
    http server v0.1_http_webapp.c
  • 原文地址:https://www.cnblogs.com/huangmr0811/p/5570966.html
Copyright © 2011-2022 走看看