zoukankan      html  css  js  c++  java
  • jsp---tomcat===》》内置对象

    1.内置对象:

       request:

    方法:getParameter("txtName"):获取和页面上的name属性对象的value值

          返回String

          getParameterValues():字符串数组

    2.解决乱码

          post乱码解决方案

          request.setCharactorEncoding("utf-8");

          get乱码解决方案

          String st=new String(getParameter("txtName").getBytes("iso-8859-1"),"utf-8");

    3.转发和重定向区别

       ①请求次数,转发1次,重定向2次

       ②url地址角度,转发是中间页面地址,重定向最后页面地址

       ③携带数据角度 转发携带数据,而重定向不携带数据

    4.session讲解,一次回话

     给session域中扔值

         session.setAttribute("key","value");

     

    取值

    Object oo=session.getAttribute("key");

    5.response响应对象

    ---->addCookie(new Cookie());

    ---->sendRedirect("目标地址");

    6.为什么要给session中放入用户名?

    解析:可以将值保留到域中,以便下次访问。

    7.include

    <%@ include file="jsp文件的路径"%>

    静态导入

    如何书写动态导入代码

        <jsp:include>

        区别:静态导入,1个类

              动态导入,2个类

    8.Application对象

    Application作用域√最大

    session作用域

    request作用域

    9.如何写入cookie

    用:

    给cookie设置时间

    Cookie cookies=new Cookie("Myuser","admin");

    cookie.setMaxAge(60*60*24);

    response.addCookie();

    如何获取?

    Cookie[] cookies=request.getCookies();

    //特定cookies  对比Myuser

    for(int i<0;i<cookies.length;i++){

    if(cookies[i].getName().equals("Myuser")){

       //定向success

      }

    }

  • 相关阅读:
    jquery堆栈与队列
    类数组转成数组对象
    python基础教程总结8——特殊方法,属性,迭代器,生成器,八皇后问题
    python基础教程总结7——异常
    python基础教程总结6——类
    python基础教程总结5——函数
    python基础教程总结4—基本语句
    python——动态类型
    python基础教程总结3—字典
    python基础教程总结2——字符串
  • 原文地址:https://www.cnblogs.com/hfddz/p/6755754.html
Copyright © 2011-2022 走看看