zoukankan      html  css  js  c++  java
  • Java EE javax.servlet ServletContainerInitializer接口

    ServletContainerInitializer接口

      public interface ServletContainerInitializer

     

      一、介绍

      该接口,允许在 web 应用程序的启动阶段通知Library/Runtime, 并执行对Servlets、Filters和Listeners的任何必需的编程注册。

      此接口的实现必须由位于META-INF/services 目录内的JAR文件资源声明, 并以此接口的完全限定类名命名,and will be discovered using the runtime's service provider lookup mechanism or a container specific mechanism that is semantically equivalent to it. 

      无论哪种情况,ServletContainerInitializer services from web fragment JAR files excluded from an absolute ordering must be ignored, and the order in which these services are discovered must follow the application's classloading delegation model.

     

      二、方法

      1、void onStartup(Set<Class<?>> c,ServletContext ctx) throws ServletException

      将指定的ServletContext所表示的应用程序的启动,告诉这个ServletContainerInitializer。

      如果将此 ServletContainerInitializer 绑定到应用程序的 WEB INF/lib 目录中的 JAR 文件中, 则它的 onStartup 方法将在捆绑应用程序启动期间只调用一次。

      如果此 ServletContainerInitializer 被捆绑在任何 WEB INF/lib 目录之外的 JAR 文件中, 但仍可发现, 如上文所述, 则每次启动应用程序时都会调用其 onStartup 方法。

     

      参数信息:

      c,the Set of application classes that extend, implement, or have been annotated with the class types specified by the HandlesTypes annotation, or null if there are no matches, or this ServletContainerInitializer has not been annotated with HandlesTypes

      ctx,the ServletContext of the web application that is being started and in which the classes contained in c were found

     

     

  • 相关阅读:
    装饰设计模式
    Enum的基本使用
    java根据文件流判断文件类型(后缀名)
    Java正则表达式的用法
    java遍历Map
    java操作json
    struts2+ajax+jquery
    Hibernate注解
    oracle经典建表语句--scott建表
    Struts2 ui标签
  • 原文地址:https://www.cnblogs.com/bigbigbigo/p/8844188.html
Copyright © 2011-2022 走看看