• Servlet常用类和接口


    Servlet常用类和接口:
      1,servlet接口
       所有servlet直接或者间接实现的接口
       主要方法:
        void init(ServletConfig sc)
        ServletConfig getServletConfig()
        String getServletInfo();
        void service(ServletRequest req,ServletResponse resp)
        void destory()
      2,HtppServlet抽象类
       它重写了service方法,针对客户请求类型不同提供不同的方法:doPost(),doGet()
      3,ServletRequest接口和ServletResponse接口
       当用户请求到来时,Servlet容器会创建一个ServletRequest对象封装请求数据,同时创建ServletResponse对象封装响应数据
       ServletRequest主要方法:
        Object getAttribute(String name)  //返回属性名为name的属性值
        Enumeration getAttributeNames()  //返回请求中所有的属性
        void removeAttribute(String name)
        void setAttribute(String name,Object obj)
        String getCharacterEncoding();
        String getParameter(String name)//返回请求name参数的值
        Enumeration getParameterNames()
        ServletOutputStream getOutputStream() //用来发送对客户端的响应
        PrintWrite getWrite() //用来将字符文本发送到客户端    out.println("daduh");
      4,HttpServletRequest接口
       Cookie[] getCookies();
       HttpSession getSession();
      5,HttpServletResponse接口
       void addCookie(Cookie cookie);
      6,HttpSession接口
       String getId()
       String getAttribute(String name)
       void setAttribute(String name,Object obj)
       Enumeration getAttributeNames()

  • 相关阅读:
    LInux-crontab
    Linux权限-chmod1
    Tool_BurpSuite安装和简单使用
    python与redis交互(四)
    Flask_环境部署(十六)
    Nginx_配置文件nginx.conf配置详解
    Tool_linux环境安装python3和pip
    Nginx_全局命令设置
    Linux_无法解析域名
    VMware_克隆机器后主机Ping不同虚拟机,虚拟机能Ping通主机
  • 原文地址:https://www.cnblogs.com/dengyuanqi/p/6378326.html
Copyright © 2020-2023  润新知