zoukankan      html  css  js  c++  java
  • Servlet-HttpServlet对象

    概述

    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; // 接口
    
  • 相关阅读:
    正则与普通方法对字符串过滤的比较
    java基础练习笔记
    node.js-express路由基础+获取前端数据+rmvc架构开发
    解决powershell因为在此系统上禁止运行脚本"报错
    树、森林、二叉树的转换
    git提交代码时如何不提交node_modules文件
    node.js-静态资源目录搭建
    node.js路由基础
    sql server查询练习
    MYQL存储过程与事件
  • 原文地址:https://www.cnblogs.com/shenleg/p/14254458.html
Copyright © 2011-2022 走看看