Servlet-HttpServlet物件
阿新 • • 發佈:2021-01-09
概述
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; // 介面