zoukankan      html  css  js  c++  java
  • 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则是饿汉式(如果有多个时,值越小越先加载)

  • 相关阅读:
    LoadRunner创建脚本和场景流程
    Monitorix系统和网络监控工具
    查询日志logcat使用总结
    SqlServer存储过程示例
    编写sql查询语句思路
    dstat工具使用介绍
    dstat参数选项
    SqlServer50条常用查询语句
    MySQL查询示例
    CMake 常用方法
  • 原文地址:https://www.cnblogs.com/dxwen/p/10841631.html
Copyright © 2011-2022 走看看