首页 > 其他 > 详细

Servlet生命周期

时间:2017-10-02 11:38:25      阅读:273      评论:0      收藏:0      [点我收藏+]
 1 //servlet生命周期
 2 /* 
 3   init();初始化
 4   service();处理客户端请求
 5   destroy();终止(销毁)
 6 */
 7 
 8 //init()方法
 9 public void init() throws ServletException{
10     //初始化代码...
11 }
12 
13 
14 //service()方法
15 public void service(ServletRequest request,ServletResponse response) throws ServletException,IOException{
16 
17 }
18 /*
19   service() 方法由容器调用,service 方法在适当的时候调用 doGet、doPost、doPut、doDelete 等方法;
20   不用对service() 方法做任何动作,只需要根据来自客户端的请求类型来重写 doGet() 或 doPost() 即可.
21 */
22 
23     //doGet()方法
24     public void doGet(ServletRequest request,ServletResponse response) throws ServletException,IOException{
25         //servlet代码
26     }
27     //doPost()方法
28     public void doPost(ServletRequest request,ServletResponse response) throws ServletException,IOException{
29         //servlet代码
30     }
31 
32 
33 //destroy()方法
34 public void destroy(){
35     //终止化代码
36 }

技术分享

Servlet生命周期

原文:http://www.cnblogs.com/yanxi1900/p/7619822.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!