servlet 生命周期_Servlet生命周期

servlet 生命周期

servlet life cycle
  1. Loading Servlet Class : A Servlet class is loaded when first request for the servlet is received by the Web Container.

    加载Servlet类:当Web容器收到对Servlet的首次请求时,将加载Servlet类。

  2. Servlet instance creation :After the Servlet class is loaded, Web Container creates the instance of it. Servlet instance is created only once in the life cycle.

    创建Servlet实例:加载Servlet类后,Web Container会创建它的实例。 Servlet实例在生命周期中仅创建一次。

  3. Call to the init() method : init() method is called by the Web Container on servlet instance to initialize the servlet.

    调用init()方法: Web容器在servlet实例上调用init()方法以初始化servlet。

    Signature of init() method :

    init()方法的签名:

    public voidinit(ServletConfig config) throws ServletException
    
  4. Call to the service() method : The containers call the service() method each time the request for servlet is received. The service() method will then call the doGet() or doPost() methos based ont eh type of the HTTP request, as explained in previous lessons.

    调用service()方法:每次收到servlet请求时,容器都会调用service()方法。 然后,service()方法将根据HTTP请求的类型调用doGet()doPost()方法,如先前课程中所述。

    Signature of service() method :

    service()方法的签名:

    public voidservice(ServletRequest request, ServletResponse response) throws ServletException, IOException
    
  5. Call to destroy() method: The Web Container call the destroy() method before removing servlet instance, giving it a chance for cleanup activity.

    调用destroy()方法: Web容器在删除servlet实例之前调用destroy()方法,从而使其有机会进行清理活动。

翻译自: https://www.studytonight.com/servlet/servlet-life-cycle.php

servlet 生命周期

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值