摘要: Servlet的生命周期据是面试的时候常问的问题,所以总结一下。生命全过程:加载 ClassLoader 实例化 new 初始化 init(ServletConfig)处理请求 service doGet doPost退出服务 destroy()特别强调:从头到尾只有一个对象,而且在客户端第一次访问Servlet的时候Tomcat new出一个对象。init()//只执行一次, 第一次初始化的时候处理请求是以多线程的方式处理的destroy()//webapp 退出的时候例子:import java.io.IOException;import javax.servlet.ServletConf 阅读全文
posted @ 2012-08-03 11:38 Jojojojoo 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 首先我们可以看到在javax.servlet包下有个servlet接口,实现接口的子类有GenericServlet,打开文档可以看到GenericServlet类有两个init()方法。voidinit() A convenience method which can be overridden so that there's no need to call super.init(config). voidinit(ServletConfig config) Called by the servlet container to indicate to a servlet that t 阅读全文
posted @ 2012-08-03 11:37 Jojojojoo 阅读(363) 评论(0) 推荐(0) 编辑