zoukankan      html  css  js  c++  java
  • request常用的方法

     request方法综合:--

    返回请求方式:-request.getMethod()-----GET
    返回URI中的资源名称(位于URL中端口后的资源路径):-request.getRequestURI()-----/myservlet/RequestMethodColligate.html
    返回URL中的参数部分:-request.getQueryString()-----null
    返回URL中的协议名:-request.getProtocol()-----HTTP/1.1
    返回所属于的路径WEB站点:-request.getContextPath()-----/myservlet
    返回额外信息路径:-request.getPathInfo()-----null
    返回额外信息所对应的资源的真实路径:-request.getPathTranslated()-----null
    返回SERVLET所映射的路径在XML文档中设置:-request.getServletPath()-----/RequestMethodColligate.html


    -----------------------------------------------


    以下为获取网络连接信息,在ServletRequest接口的方法综合实例:------


    ------获取客户机上的有:---
    获取客户机的IP地址:--request.getRemoteAddr()-------127.0.0.1
    获取客户机的主机名:--request.getRemoteHost()-------127.0.0.1
    获取客户机的端口号:--request.getRemotePort()-------1373
    获取客户机发出请求时的完整URL:--request.getRequestURL()-------http://localhost:8080/myservlet/RequestMethodColligate.html


    ------以下为获取本地服务器中的网络信息有:-----


    服务器接收当前的网络接口的IP地址:--request.getLocalAddr()-------127.0.0.1
    所对应的主机名:--request.getLocalName()-------localhost
    对应的端口号:--request.getLocalPort()-------8080
    获取当前请求所指向的主机名:--request.getServerName()-------localhost
    获取当前请求的所连接的服务器端口号:--request.getServerPort()-------8080
    获取请求的协议名:--request.getScheme()-------http

  • 相关阅读:
    Access Token 机制详解
    Authorization Code 授权原理和实现方法
    Access Token 与 Refresh Token
    简单介绍 Oauth2.0 原理
    进行web开发时应该考虑的架构性因素
    查看linux服务器CPU数量
    Centos7 修改主机名
    Centos6 编译安装Python3.6
    Linux编译安装软件常见问题及排查
    问题列表
  • 原文地址:https://www.cnblogs.com/haw2106/p/7883999.html
Copyright © 2011-2022 走看看