zoukankan      html  css  js  c++  java
  • JAVA Web知识点整理(三)

    ServletRequest父接口

    (1)请求参数相关的方法

       String getParameter(String name)         //获取单值参数     常用
    
       String[] getParameterValues(String name)     //获取多值参数     常用
    
       Enumeration getParameterNames()         //获取全部请求参数名
    
       Map getParameterMap()                 //获取全部请求参数名-值对 

    (2)字符编码相关的方法

       String getCharacterEncoding()          //获取字符编码 
    
       void setCharacterEncoding(String charset)     //设置字符编码    常用

    (3)获取请求转发器

    RequestDispatcher getRequestDispatcher(String path)   常用

    (4)属性操作相关的方法

       Object getAttribute(String name)         //获取属性    常用
    
       void setAttribute(String name, Object o)     //设置属性    常用
         
       void removeAttribute(String name)         //删除属性    常用
       
       Enumeration getAttributeNames()            //获取全部属性名

    (5)服务器和客户端相关的方法

       String getProtocol()   // 协议名称/协议版本号
       String getScheme()     // 协议名称
    
    
       String getLocalName()  // 服务器主机名
       String getLocalAddr()  // 服务器IP地址
       int getLocalPort()        // 服务器端口号
    
    
       int getServerName()        // 服务器主机名
       int getServerPort()     // 服务器端口号
    
       
       String getRemoteHost()   // 客户端主机名
       String getRemoteAddr()   // 客户端IP地址
       int getRemotePort()      // 客户端端口号  

    (6)字节流和字符流相关的方法

    ServletInputStream getInputStream()   // 获取输入字节流
    
    BufferedReader getReader()          // 获取输入字符流

    HttpServletRequest子接口---封装请求信息,对应JSP的request内置对象

    (1)请求URL路径相关的方法
    
       String getContextPath()  // 获取项目名   /TestJSP    常用
    
       String getServletPath()  // 获取服务器路径 /test/request_info.jsp
    
       String getRequestURI()  // 获取请求地址  /TestJSP/test/request_info.jsp    常用
    
       StringBuffer getRequestURL()  // 获取完整URL  http://localhost:8080/TestJSP/test/request_info.jsp?username=etc&password=123
    
       String getQueryString() // 获取请求参数列表 username=etc&password=123
    
       String getRealPath(String path) // 真实物理路径  E:workspace_jee_new.metadata.pluginsorg.eclipse.wst.server.core	mp0wtpwebappsTestJSPimage
    
    
    (2)请求头相关的方法
    
       String getMethod()            // 获取请求方法      常用
    
       int getContentLength()        // 获取请求体中的请求长度
    
       String getContentType()        // 获取请求体中的MIME类型
    
       String getHeader(String name)   // 获取指定名称的请求头信息
             
       Enumeration getHeaderNames()    // 获取全部的请求头名称
     
       Enumeration getHeaders(String name)  
     
    
    (3)Cookie[] getCookies()      // 获取客户端保存的全部Cookie对象    常用
     
    
    (4)HttpSession getSession()   // 获取session对象    常用
  • 相关阅读:
    vsc连接wsl时node进程占用cpu高
    LifeCycles属性
    让kbmMWClientQuery更新视图
    uniGUI免登录的实现
    uniGUI 快速定制手机端输入界面布局
    更新IDE的背景
    Delphi 10.4.1来了
    如何修改windows服务器最大的tcp连接数
    uniGUI怎么升级jquery
    【转】UniGUI的布局使用说明
  • 原文地址:https://www.cnblogs.com/sheng-se/p/14376425.html
Copyright © 2011-2022 走看看