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

  • 相关阅读:
    [置顶] 对于最新的Android病毒,Smack完全可以抵御
    Android的Recovery中font_10x10.h字库文件制作
    杭电 汉诺塔问题总结
    [置顶] Android访问控制系统测试与评估
    HDU4662+无
    进制转换练习题两道
    X Shell 4配色方案[Solarized Dark]
    hdu2795Billboard(线段树)
    H面试程序(10): 字符串包含问题
    find-k-pairs-with-smallest-sums
  • 原文地址:https://www.cnblogs.com/haw2106/p/7883999.html
Copyright © 2011-2022 走看看