• 关于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 也配置中也配置一下。

  • 相关阅读:
    K8s--09 编写mysql的持久化deployment
    K8s--08 prometheus监控
    K8s--07 configMap资源
    K8s--06 K8s数据持久化
    k8S--05 K8s控制器类型
    k8s--04 部署harbor作为k8s镜像仓库
    K8s--03 资源类型
    K8s--02 K8S部署
    K8s--01 Kubernetes简介
    video2gift环境安装(Theano等)
  • 原文地址:https://www.cnblogs.com/huangmr0811/p/5570966.html
Copyright © 2020-2023  润新知