`

关于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,让容器在启动的时候能发现有这个文件存在。
分享到:
评论
1 楼 王庆波-行 2016-02-26  
逻辑好清晰,学习了,感谢分享!

相关推荐

    cas 配置client 1.0 &2.0 及proxy DEMO 说明

    &lt;/welcome-file-list&gt; &lt;/web-app&gt; 4 cas client 2.0配置说明 &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi=...

    最简化velocity的web工程

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.vm&lt;/welcome-file&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; 3.index.vm代码 $!isSuccess 4.访问地址 http://IP:端口/vlo/hello ...

    生活轨迹SSH服务端

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;!-- 默认找的...

    一个在线报名系统

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;welcome-file&gt;default.html&lt;/welcome-file&gt; &lt;welcome-file&gt;...

    Spring MVC 框架应用实例

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;jsp-config&gt; &lt;taglib&gt; &lt;taglib-uri&gt;http://java.sun.com/jsp/jstl/core...

    web.xml详解(web-app_2_3.dtd)

    部署描述文件web.xml详解(web-app_2_3.dtd),全面介绍: 1. icon元素 2. display-name元素 3. description元素 4. distributable元素 5. context-param元素 6. filter元素 7. filter-mapping元素 8. ...

    SpringStrutsHibernate的配置

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; 把servlet-name等的servlet改为filter就变成了过滤器了。 说明:要继承HttpServlet类 一、 ①处可以随便取一个名字,但一般是和...

    t淘淘商城项目 商城项目 视频和源码教程 详细

    &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt; &lt;version&gt;${spring.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt; &lt;version&gt;${...

    聊天室(ActionScript 3.0实现)

    聊天室(ActionScript 3.0实现)&lt;?xml version="1.0" encoding="UTF-8"?&gt; -&lt;web-app xsi:schemaLocation=...-&lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt;

    Spring MVC 入门实例

    45 &lt;welcome-file-list&gt; 46 &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; 47 &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; 48 &lt;/welcome-file-list&gt; 49 50 &lt;jsp-config&gt; 51 &lt;taglib&gt; 52 &lt;taglib-uri&gt;...

    servlet3.0新特性源代码

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; */ @SuppressWarnings(...

    JSF文件上传

    &lt;/welcome-file-list&gt; &lt;/web-app&gt; 上传文件的页面如下: &lt;%@ include file="tags.jsp"%&gt; &lt;f:view&gt; &lt;h:form id="MyForm" enctype="multipart/form-data" &gt; &lt;h:messages globalOnly="true" styleClass="message"/&gt;...

    基于EXT SSI的简单树实现

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;page/index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;!-- web应用启动时初始化applicationContext --&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context....

    struts2配置2.5版

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;!-- 配置核心拦截器 --&gt; &lt;filter&gt; &lt;filter-name&gt;struts2&lt;/filter-name&gt; &lt;!-- Filter的实现类 struts2.5 --&...

    struts项目搭建

    &lt;/welcome-file-list&gt; &lt;login-config&gt; &lt;auth-method&gt;BASIC&lt;/auth-method&gt; &lt;/login-config&gt; &lt;/web-app&gt; 然后在src目录下新建一个struts.xml文件,内容如下: &lt;!DOCTYPE struts PUBLIC "-//Apache Software ...

    spring_MVC源码

    弃用了struts,用spring mvc框架做了几个项目,感觉都不错,而且使用了注解方式,可以省掉一大堆配置文件。本文主要介绍使用注解方式配置的spring mvc,之前写的spring3.0 mvc和rest小例子...02.&lt;web-app xmlns:xsi=...

    项目源码-java计算机配件报价系统项目

    【项目源码】-java计算机配件报价系统项目 系统主要功能包括: 前台功能模块:系统首页、我的信息、留言板、用户登陆、公告以及日历模块 ... &lt;welcome-file-list&gt; &lt;welcome-file&gt;/qiantai/default.

    cms后台管理

    &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.html&lt;/welcome-file&gt; &lt;welcome-file&gt;index.shtml&lt;/welcome-file&gt; &lt;welcome-file&gt;index.jhtml&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; 通过以上标签找到应该加载哪一个...

    VB编程资源大全(英文源码 其它)

    6 , chunks.zip&lt;br&gt;This will open a file and read it in "Chunks" of a selected file.&lt;END&gt;&lt;br&gt;7 , logging.zip&lt;br&gt;This is a bas that will log installation procedures so the file can be removed later.&lt;END...

    BIG文件编辑器

    To open a BIG file, just click on File-&gt;Open and select your BIG file. You can now browse the files included in this BIG file. However, you can also edit it. You can do this either by using the Edit ...

Global site tag (gtag.js) - Google Analytics