zoukankan      html  css  js  c++  java
  • JSP常用内置对象方法

    request方法
    获取单个值:request.getParameter(name值);
    获取一组值:request.getParameterValues(name值);
    设置字符编码:request.setCharacterEncoding(字符编码);
    存储值:request.setAttribute(k,v);

    转发:request.getRequestDispatcher("地址").forward(request,response);

    response方法
    重定向:response.sendRedirect("地址");
    设置字符编码:response.setCharacterEncoding(字符编码);
    添加cookie:response.addCookie(Cookie cook);

    session方法
    设置会话:session.setAttribute(k,v);
    读取会话:session.getAttribute(k);
    设置生命期:session.setMaxInactiveInterval();
    取消生命周期:session.invalidate();
    获取sessionid:session.getId();
    删除指定session对象:session.removeAttribute(k);

    application方法
    保存值:application.setAttribute(k,v);
    读取值:application.getAttribute(k);
    返回相对路径的真实路径:application.getRealPath();

    include 方法
    <%@ include file="jsp|html|css|text" %>

    导入包
    <%@ page import="包名.*,包名.*" %>

    cookie方法
    设置有效期:cookie.setMaxAge();
    创建后赋值:cookie.setValue();
    获取名称:cookie.getName();
    获取值:cookie.getValue();
    获取有效时间:cookie.getMaxAge();

  • 相关阅读:
    barcode制作条形码及破解
    软件敏捷架构师
    软件需求分析三步走
    GDI+显示GIF动画
    CSpinButtonCtrl的弱智问题
    [C++] STL里面的map
    [C#] 再议Exception
    [C++] unsigned是麻烦制造者
    用GDI+转BMP为WMF、EXIF、EMF格式
    [C++] 编译时的warning
  • 原文地址:https://www.cnblogs.com/SHZX/p/8384268.html
Copyright © 2011-2022 走看看