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则是饿汉式(如果有多个时,值越小越先加载)

  • 相关阅读:
    Linux下安装配置SVN服务器,windows访问
    Zookeeper集群版搭建
    Zookeeper单机版启动
    Nginx-Session缓存一致性-memcached
    Nginx-配置多台Tomcat-反向代理
    Linux-tomcat-安装启动
    Linux-JDK-环境搭建安装
    Nginx-安装-运行访问页面
    Linux-虚拟机-克隆-学习
    解决CocosCreator 在微信小游戏中使用Socket.io 报错的问题
  • 原文地址:https://www.cnblogs.com/dxwen/p/10841631.html
Copyright © 2011-2022 走看看