01_4_SERVLET声明周期

01_4_SERVLET声明周期

1. Servlet的生命周期

生命全过程

加载ClassLoader

实例化 new

//客户端第一次请求的时候,只new一次

初始化init(ServletConfig)

处理请求service do Get doPost

退出服务destroy()

只有一个对象

API中的过程

init()//只执行一次,第一次初始化的时候

public void init(ServletConif config) throws ServletException

service()

public void service(ServletRequest req, ServleteResponse res) throws ServletException, IOException

destroy() //webapp退出时候

public void destroy()

原文地址:https://www.cnblogs.com/flyback/p/8680969.html