概述
servlet-api 4.0.1版本
常用方法
HttpServlet
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {...}
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {...}
protected void doPut(HttpServletRequest req, HttpServletResponse resp) {...}
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) {...}
protected void service(HttpServletRequest req, HttpServletResponse resp) {...} // 负责调用上面四种方法
GenericServlet实现类
public void init() throws ServletException {}
public void destroy() {}
public String getInitParameter(String name) {...}
public Enumeration<String> getInitParameterNames() {}
public ServletConfig getServletConfig() {...} // 获取ServletConfig对象
public String getServletInfo() {...}
public ServletContext getServletContext() {...} // 获取ServletContext对象
public String getServletName() {...}
public abstract void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;
ServletConfig接口
servlet容器使用的servlet配置对象,用于在初始化期间将信息传递给servlet。
public String getServletName(); // 接口
public ServletContext getServletContext(); // 接口
public String getInitParameter(String name); // 接口
public Enumeration<String> getInitParameterNames(); // 接口
Servlet接口
public void init(ServletConfig config) throws ServletException; // 接口
public void destroy(); // 接口
public ServletConfig getServletConfig(); // 接口
public String getServletInfo(); // 接口
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException; // 接口