Servlet之web.xml下welcome-file-list简介说明

java-教程王 Servlet 发布时间:2021-12-11 12:50:19 阅读数:15608 1
下文讲述web.xml下welcome-file-list选项的简介说明,如下所示:

welcome-file-list选项的用途

在web.xml文件的web-app下的
welcome-file-list子元素用于定义欢迎文件列表
子元素为welcome-file
用于设置项目默认的加载页面地址
注意事项:
    当未找到welcome-file-list下的文件或未设置其信息,
	则默认都会返回404错误
例:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="WebApp_ID" version="3.1">
    <display-name>helloworld</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>test.jsp</welcome-file>
    </welcome-file-list>
</web-app>
以上设置的欢迎页面分别为:index.html,index.jsp,test.jsp
欢迎页面的访问优先级分别为index.html>index.jsp>test.jsp
当index.html存在时,则返回index.html
否则查找是否存在index.jsp 如果存在,则返回index.jsp
如果以上两个都不存在时,则查找test.jsp,如果存在,则返回test.jsp
否则返回404
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

本文链接: https://www.Java265.com/Servlet/202112/218.html

最近发表

热门文章

好文推荐

Java265.com

https://www.java265.com

站长统计|粤ICP备14097017号-3

Powered By Java265.com信息维护小组

使用手机扫描二维码

关注我们看更多资讯

java爱好者