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 }

posted on 2017-10-02 11:11  yanxi1900  阅读(137)  评论(0编辑  收藏  举报