关于web.xml中的welcome-file-list(欢迎页)
来源:互联网 发布:淘宝优惠券平台排名 编辑:程序博客网 时间:2024/05/22 06:56
例如:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.action</welcome-file>
</welcome-file-list>
今天我遇到了一个问题,运行项目时没有跳转到默认页面,而是报404找不到的错误,根据错误信息看明显是没有跳转到index.html,意思就是说welcome-file-list根本就木有起作用。
解决问题一定要从原理入手,所以要先分析welcome-file-list是怎么工作的。
welcome-file-list的工作原理是,按照welcome-file的.list一个一个去检查是否web目录下面存在这个文件,如果存在,继续下面的工作(或者跳转到index.html页面,或者配置有struts的,会直接struts的过滤工作).如上例,先去webcontent(这里是Eclipse的工程目录根目录)下是否真的存在index.html这个文件,如果不存在去找是否存在index.jsp这个文件,以此类推。
还要说的是welcome-file不一定是html或者jsp等文件,也可以是直接访问一个action。就像我上面配置的一样,但要注意的是,一定要在webcontent下面建立一个index.action的空文件,然后使用struts配置去跳转,不然web找不到index.action这个文件,会报404错误,原因就是我之前说的那样。
希望上述文章对大家有帮助,如果还有其他的可能使得欢迎页不起作用,欢迎大家给我留言。
如果配置了servlet的url-pattern是/*,那么访问localhost:8080/会匹配到该servlet上,而不是匹配welcome-file-list;如果url-pattern是/(该servlet即为默认servlet),如果其他匹配模式都没有匹配到,则会匹配welcome-file-list。
- 关于web.xml中的welcome-file-list(欢迎页)
- 关于web.xml中的welcome-file-list(欢迎页)
- 关于web.xml中的welcome-file-list(欢迎页)
- web.xml中的welcome-file-list(欢迎页)
- 关于web.xml中<welcome-file-list>
- 关于web.xml中<welcome-file-list>
- web.xml中的welcome-file-list不起作用
- web.xml中的welcome-file-list
- 关于web.xml中的<welcome-file-list>中的默认首页文件
- 关于web.xml中的<welcome-file-list>中的默认首页文件
- 关于welcome-file-list(欢迎页)不起作用的解决办法
- 关于welcome-file-list(欢迎页)不起作用的解决办法
- web.xml中<welcome-file-list>配置
- 为何web.xml中的welcome-file-list不能是Action地址
- web.xml之welcome-file-list、error-page
- web.xml(7)_mime-mapping、welcome-file-list、error-page
- web.xml里面的welcome-file-list是什么意思
- java web.xml welcome-file-list的默认值
- 多态、内部类、Object、异常
- 数据结构之顺序表(创建、使用、销毁)
- 论文阅读-《Densely Connected Convolutional Networks》
- G
- Linux基本操作系列(三):在CentOS 6.8系统上安装MySQL 5.7
- 关于web.xml中的welcome-file-list(欢迎页)
- 百练_2715:谁拿了最多奖学金
- TI 实时操作系统SYS/BIOS使用总结
- #1 介绍
- Android 快速开发系列 打造万能的ListView GridView 适配器
- 2017 省赛 山东 A Return of the Nim 【博弈】【Nim+Wythoff】
- android开源库---Dagger2学习准备(依赖注入)
- DLNA系列1:投屏到BubbleUpnp播放器出错的解决
- #bzoj1526#分梨子(乱搞)