zoukankan      html  css  js  c++  java
  • Servlet配置load-on-startup

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    metadata-complete="true" version="3.0">
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <!--
      Element : load-on-startup
    	The load-on-startup element indicates that this servlet should be 
     loaded (instantiated and have its init() called)on the startup of the 
     web application. 
     (这句话的含义是说假设设置了这个元素的值,那么在web应用程序启动的时候,会实例化这个servlet
     而且调用当中的init方法) 
     The optional contents of these element must be 
     an integer indicating the order in which the servlet should be 
     loaded. If the value is a negative integer, or the element is not 
     present, the container is free to load the servlet whenever it 
     chooses. If the value is a positive integer or 0, the container must 
     load and initialize the servlet as the application is deployed. The 
     container must guarantee that servlets marked with lower integers 
     are loaded before servlets marked with higher integers.
     (上面的含义表示假设负数或没有当前的值设置,则某个servlet不管何时在被选择的时候才载入,包含上面的
     instantiated和init)
     The container may choose the order of loading of servlets with the 
     same load-on-start-up value.(容器能够选择一个同样的value去载入servlet)
    
    Data Type : load-on-startupType
    Enumerated Values :  
       -->
      <servlet>
        <servlet-name>HelloworldServlet</servlet-name>
        <servlet-class>com.ghsy.HelloworldServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>HelloworldServlet</servlet-name>
        <url-pattern>/Helloworld</url-pattern>
      </servlet-mapping>
      <servlet>
        <servlet-name>LifecycleServlet</servlet-name>
        <servlet-class>com.ghsy.LifecycleServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>LifecycleServlet</servlet-name>
        <url-pattern>/lifecycle</url-pattern>
      </servlet-mapping>
      <servlet>
        <servlet-name>InitServlet</servlet-name>
        <servlet-class>com.ghsy.InitServlet</servlet-class>
        <init-param>
          <param-name>參数1</param-name>
          <param-value>value1</param-value>
        </init-param>
        <init-param>
          <param-name>參数2</param-name>
          <param-value>value2</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>InitServlet</servlet-name>
        <url-pattern>/init</url-pattern>
      </servlet-mapping>
      <servlet>
        <servlet-name>GenericServletDemo</servlet-name>
        <servlet-class>com.ghsy.GenericServletDemo</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>GenericServletDemo</servlet-name>
        <url-pattern>/generic</url-pattern>
      </servlet-mapping>
    </web-app>

  • 相关阅读:
    VS2010调试技巧
    asp.net中Web.Config配置文件详解
    vi进入编辑模式,按向左,向右,向上,向下,出现A,B,C,D字符解决方法
    su root后还是不能使用usermod,useradd等命令,错误描述:bash:usermod:command not found(转自http://myjieli.blog.51cto.com/135162/286462)
    启动VMware出现报错:The VMware Authorization Service is not running
    C++调用被C编译器编译过的函数要加extern "C"(转自http://zhidao.baidu.com/question/193713666.html)
    json,junit运行java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
    java生成xml文件
    java连接数据库
    eclipse_javaee运行时总是未响应
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4509293.html
Copyright © 2011-2022 走看看