• servlet02


    1、
    <!-- ==================== Default Welcome File List ===================== -->
    <!-- When a request URI refers to a directory, the default servlet looks -->
    <!-- for a "welcome file" within that directory and, if present, to the -->
    <!-- corresponding resource URI for display. -->
    <!-- If no welcome files are present, the default servlet either serves a -->
    <!-- directory listing (see default servlet configuration on how to -->
    <!-- customize) or returns a 404 status, depending on the value of the -->
    <!-- listings setting. -->
    <!-- -->
    <!-- If you define welcome files in your own application's web.xml -->
    <!-- deployment descriptor, that list *replaces* the list configured -->
    <!-- here, so be sure to include any of the default values that you wish -->
    <!-- to use within your application. -->

    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>


    当 uri的项目名后跟"/"时,会调用default对应的servlet类,default servlet会去找welcome-file里面的文件,第一个不存在找第二个,第二个不存在找第三个,所有的都不存在则会出现两种情况(哪种情况取决于listings setting的值):
    1)报错 (listings setting=false)
    2)显示项目里面的文件,文件夹(除了META-INF,WEB-INF),且这些文件,文件夹都是可以访问的(listings setting=true)
    <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>

    当uri指向一个目录,会调用default servlet,
    ps:如果指向一个文件,那么这个文件可以直接访问(无论listings setting的值)

    2、
    <load-on-startup> servlet启动时加载
    如果在<servlet>标签下配置了该标签,则表示servlet将会在服务器启动时,加载servlet,并调用servlet的init()方法
    <load-on-startup></load-on-startup>
    值为负数或不写这个元素则是懒汉式
    值为正数或0则是饿汉式(如果有多个时,值越小越先加载)

  • 相关阅读:
    48、C++ Primer 4th 笔记,句柄类,继承,虚函数等的一个综合例子(未完)
    79、在linux的man手册当中,man(1)是什么意思?
    ASP.NET2.0 ObjectDataSource的使用详解(1)
    ndts 一个使用不多重要命令
    ASP.NET2.0 ObjectDataSource的使用详解(2)
    使用自定义参数
    一步一步学习ObjectDataSource--(3)
    ASP.NET2.0快速入门--绑定到对象板(后来才发现,忘了)
    关于URL路径的基本使用
    ASP.NET2.0 快速入门 使用主题对站点进行自定义
  • 原文地址:https://www.cnblogs.com/dxwen/p/10841631.html
Copyright © 2020-2023  润新知