No.1:
public class xxx implements Servlet {
重写其中相应函数
public void init(ServletConfig param1) throws ServletException {} //只在创建servlet时执行一次
public ServletConfig getServletConfig() {}
public void service(ServletRequest req, ServletResponse res) {}
public String getServletInfo() {}
public void destroy() {}
}
No.2:
public class xxx extends HttpServlet { //应用最为广泛
//只需重写其中相应函数
public void doGet(ServletRequest req, ServletResponse res) {}
public void doPost(ServletRequest req, ServletResponse res) {}
}
No.3:
public class xxx extends GenericServlet {
//重写其中相应函数
}
public class xxx implements Servlet {
重写其中相应函数
public void init(ServletConfig param1) throws ServletException {} //只在创建servlet时执行一次
public ServletConfig getServletConfig() {}
public void service(ServletRequest req, ServletResponse res) {}
public String getServletInfo() {}
public void destroy() {}
}
No.2:
public class xxx extends HttpServlet { //应用最为广泛
//只需重写其中相应函数
public void doGet(ServletRequest req, ServletResponse res) {}
public void doPost(ServletRequest req, ServletResponse res) {}
}
No.3:
public class xxx extends GenericServlet {
//重写其中相应函数
}