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

    先看我的配置文件: 

    <welcome-file-list>  
        <welcome-file>index.html</welcome-file>  
    </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根目录下面建立个空白文件index.html,让容器在启动的时候能发现有这个文件存在。


  • 相关阅读:
    install kde in ubuntu
    Upgrade to or Install Cinnamon 2.4 in Ubuntu
    enjoy dollar vs cash dollar
    opencv linux
    高频交易都有哪些著名的算法
    wpf
    opencv mat flags含义
    gphoto2 canon eos450d
    gphoto2
    task optimization之superglue分析
  • 原文地址:https://www.cnblogs.com/rysinal/p/5834466.html
Copyright © 2011-2022 走看看