zoukankan      html  css  js  c++  java
  • Servlet (一)

    package cn.sasa.serv;
    
    import java.io.IOException;
    
    import javax.servlet.Servlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletResponse;
    
    public class QuickStart implements Servlet{
    
        @Override
        public void init(ServletConfig config) throws ServletException {
            //对象创建时执行
            //默认第一次访问时创建
            System.out.println("init......");
            //获取servlet-name
            String name = config.getServletName();
            System.out.println(name);
            //获取初始化参数
            String paramId = config.getInitParameter("id");
            System.out.println(paramId);
            //ServletContext对象
            ServletContext context = config.getServletContext();
        }
    
        @Override
        public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
            //每次访问都执行
            System.out.println("service......");
            HttpServletResponse resp = (HttpServletResponse)res;
            resp.getWriter().write("hi");;
        }
        
        @Override
        public void destroy() {
            //销毁
            System.out.println("destroy.......");
        }
    
        @Override
        public ServletConfig getServletConfig() {
            //配置信息
            return null;
        }
    
        @Override
        public String getServletInfo() {
            return null;
        }
    
    }
  • 相关阅读:
    platform_device和platform_driver
    理解和认识udev
    platform_device和platform_driver
    bzImage的概要生成过程
    shell 字符表
    分析mtk6516如何加入自己的驱动
    理解和使用Linux的硬件抽象层HAL
    bzImage的概要生成过程
    理解和认识udev
    shell 字符表
  • 原文地址:https://www.cnblogs.com/SasaL/p/10600484.html
Copyright © 2011-2022 走看看