zoukankan      html  css  js  c++  java
  • Servlet Web

    1.ServletContext    HttpServlet   Session    Cookie     ServletConfig    HttpServletRequest HttpServletResponse    ServletRequest  ServletResponse   

           (1) ServletContext :   getServletContext().setAttribute()   ..   addFilter   addListner   addServlet    ...getContextPath()

           (2) HttpServlet:   

          public class DemoServlet  implements  HttpServlet{

                 doGet(httpservletrequest, httpservletresponse){};

                doPost(httpservletrequest,httpservletresponse){};

            }

      (3)Session: 创建  使用  保存   销毁

        request.getSession().setAttribute(key,value)

        request.getSession().invalidate();

        request.getSession().removeAttribute();

        setMaxInactiveInterval(int second);

      (4) Cookie: 创建  使用  发送  保存

                         request.getCookies()读取Cookies 

           Cookie  cookie=new Cookie(name,value);

            response.addCookie(cookie );

      (5)  request  response  请求header   body

                         request.getContentType();

                         request.setCharacterEncoding("utf-8")

                         request.getParameter(name)

          response.setContentType()

          response.setCharacterEncoding()

          request.getRequestDispatch("xxx.html").forward(request,response) 请求页面跳转,地址不变,传递数据?

          response.sendRedirect(“xxx.html”) 响应跳转页面

      附:  Propertites  prop=new Properties(); 

          request.getContextServlet().getResourceAsStream()    getResourceRealPath()

          prop.load(inputStream)

          prop.get(name);

          response.getWriter()

          response.getOutputStream()

          下载文件请求头:setHeader("Content-Disposition", "attachment;fileName)

    2.Filter:

         public class DemoFilter  implements Filter{

                    init(){.....  }

                    doFilter(req,res,FilterChain){。。。。。};

                    destroy(){....};

                      }

    3.Interceptor:   

          public class  DemoInterceptor  implements HandlerInterceptor{

              

            }

    4.Listener :   

    • 对象自身的创建和销毁的监听器
    • 对象中属性的创建和消除监听器
    • session中的某个对象的状态变化监听器

        • 对象自身的创建和销毁的监听器
        • 对象中属性的创建和消除监听器
        • session中的某个对象的状态变化监听器
    • ServletContext对象监听器                   
    • HttpSession对象监听器
    • ServletRequest对象监听

    5. Java1.图片创建 2.创建图片笔刷   3.用笔刷绘制内容    4.ImageIO 

    6.JDBC :

          1.mysql.url     username  password   

         2.载入驱动jar driver   

        3.连接mysql connection  jdbcManager.getConnection()   

         4.preparedStament(sql)===>ResultSet

    7.

  • 相关阅读:
    NOIP201208同余方程
    NOIP模拟赛 最佳组合
    NOIP模拟赛 拓展
    CF1253E Antenna Coverage(DP)
    LOJ6033「雅礼集训 2017 Day2」棋盘游戏 (博弈论,二分图,匈牙利算法)
    CF582E Boolean Function(DP,状态压缩,FMT)
    CF750G New Year and Binary Tree Paths(DP)
    Codeforces Round 596 题解
    AGC008E Next or Nextnext(组合计数,神奇思路)
    ARC082E ConvexScore(神奇思路)
  • 原文地址:https://www.cnblogs.com/chencn/p/12294638.html
Copyright © 2011-2022 走看看