`

获得Request请求相关参数

阅读更多

\\\\\\\\\\相关信息\\\\\\\\\\\
String url=request.getRequestURL().toString();//http://localhost:8080/myshop/order.do
String que=request.getQueryString();//task=gotoOrder           
from = url + "?" + que;
request.setAttribute("from", from); 

 

System.out.println("rotocol: " + request.getProtocol());
System.out.println("Scheme: " + request.getScheme());
System.out.println("Server Name: " + request.getServerName() );
System.out.println("Server Port: " + request.getServerPort());
System.out.println("rotocol: " + request.getProtocol());
System.out.println("Server Info: " + request.getSession().getServletContext().getServerInfo());
System.out.println("Remote Addr: " + request.getRemoteAddr());
System.out.println("Remote Host: " + request.getRemoteHost());
System.out.println("Character Encoding: " + request.getCharacterEncoding());
System.out.println("Content Length: " + request.getContentLength());
System.out.println("Content Type: "+ request.getContentType());
System.out.println("Auth Type: " + request.getAuthType());
System.out.println("HTTP Method: " + request.getMethod());
System.out.println("ath Info: " + request.getPathInfo());
System.out.println("ath Trans: " + request.getPathTranslated());
System.out.println("Query String: " + request.getQueryString());
System.out.println("Remote User: " + request.getRemoteUser());
System.out.println("Session Id: " + request.getRequestedSessionId());
System.out.println("Request URI: " + request.getRequestURI());
System.out.println("Servlet Path: " + request.getServletPath());
System.out.println("Accept: " + request.getHeader("Accept"));
System.out.println("Host: " + request.getHeader("Host"));
System.out.println("Referer : " + request.getHeader("Referer"));
System.out.println("Accept-Language : " + request.getHeader("Accept-Language"));
System.out.println("Accept-Encoding : " + request.getHeader("Accept-Encoding"));
System.out.println("User-Agent : " + request.getHeader("User-Agent"));
System.out.println("Connection : " + request.getHeader("Connection"));
System.out.println("Cookie : " + request.getHeader("Cookie"));
System.out.println("Created : " + request.getSession().getCreationTime());
System.out.println("LastAccessed : " + request.getSession().getLastAccessedTime());

System.out.println("Protocol: " + request.getProtocol());
System.out.println("Scheme: " + request.getScheme());
System.out.println("Server Name: " + request.getServerName() );
System.out.println("Server Port: " + request.getServerPort());
System.out.println("Protocol: " + request.getProtocol());
System.out.println("Server Info: " + request.getSession().getServletContext().getServerInfo());
System.out.println("Remote Addr: " + request.getRemoteAddr());
System.out.println("Remote Host: " + request.getRemoteHost());
System.out.println("Character Encoding: " + request.getCharacterEncoding());
System.out.println("Content Length: " + request.getContentLength());
System.out.println("Content Type: "+ request.getContentType());
System.out.println("Auth Type: " + request.getAuthType());
System.out.println("HTTP Method: " + request.getMethod());
System.out.println("Path Info: " + request.getPathInfo());
System.out.println("Path Trans: " + request.getPathTranslated());
System.out.println("Query String: " + request.getQueryString());
System.out.println("Remote User: " + request.getRemoteUser());
System.out.println("Session Id: " + request.getRequestedSessionId());
System.out.println("Request URI: " + request.getRequestURI());
System.out.println("Servlet Path: " + request.getServletPath());
System.out.println("Accept: " + request.getHeader("Accept"));
System.out.println("Host: " + request.getHeader("Host"));
System.out.println("Referer : " + request.getHeader("Referer"));
System.out.println("Accept-Language : " + request.getHeader("Accept-Language"));
System.out.println("Accept-Encoding : " + request.getHeader("Accept-Encoding"));
System.out.println("User-Agent : " + request.getHeader("User-Agent"));
System.out.println("Connection : " + request.getHeader("Connection"));
System.out.println("Cookie : " + request.getHeader("Cookie"));
System.out.println("Created : " + request.getSession().getCreationTime());
System.out.println("LastAccessed : " + request.getSession().getLastAccessedTime());


\\\\\\\\\\\\\\\\\\\\\\\\\输出结果\\\\\\\\\\\\\\\\\\\
rotocol: HTTP/1.1
Scheme: http
Server Name: localhost
Server Port: 8080
rotocol: HTTP/1.1
Server Info: Apache Tomcat/6.0.14
Remote Addr: 127.0.0.1
Remote Host: 127.0.0.1
Character Encoding: UTF-8
Content Length: -1
Content Type: null
Auth Type: null
HTTP Method: GET
ath Info: null
ath Trans: null
Query String: task=gotoLogin
Remote User: null
Session Id: D8A6D983BCBED9BE2067D7AEA704D1D0
Request URI: /myshop/users.do
Servlet Path: /users.do
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/QVOD, application/QVOD, */*
Host: localhost:8080
Referer :
http://localhost:8080/myshop/product.do?task=getProductByCategoryId&fid=11
Accept-Language : zh-cn,en-us;q=0.5
Accept-Encoding : gzip, deflate
User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 661; Maxthon; (R1 1.6); .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Connection : Keep-Alive
Cookie : JSESSIONID=D8A6D983BCBED9BE2067D7AEA704D1D0; myshop.cart=%7B%22ftotleintegral%22%3A56%2C%22list%22%7D%5D%2C%22ftotalmoney%22%3A40%7D
Created : 1282313379078
LastAccessed : 1282314993625
Protocol: HTTP/1.1
Scheme: http
Server Name: localhost
Server Port: 8080
Protocol: HTTP/1.1
Server Info: Apache Tomcat/6.0.14
Remote Addr: 127.0.0.1
Remote Host: 127.0.0.1
Character Encoding: UTF-8
Content Length: -1
Content Type: null
Auth Type: null
HTTP Method: GET
Path Info: null
Path Trans: null
Query String: task=gotoLogin
Remote User: null
Session Id: D8A6D983BCBED9BE2067D7AEA704D1D0
Request URI: /myshop/users.do
Servlet Path: /users.do
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-silverlight, application/QVOD, application/QVOD, */*
Host: localhost:8080
Referer :
http://localhost:8080/myshop/product.do?task=getProductByCategoryId&fid=11
Accept-Language : zh-cn,en-us;q=0.5
Accept-Encoding : gzip, deflate
User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 661; Maxthon; (R1 1.6); .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Connection : Keep-Alive
Cookie : JSESSIONID=D8A6D983BCBED9BE2067D7AEA704D1D0; myshop.cart=%7B%22ftotleintegral
Created : 1282313379078
LastAccessed : 1282314993625

 

/////////////////////////
String sc=request.getScheme();//http
String sn=request.getServerName();//localhost
int sp=request.getServerPort(); //8080 
String cpath=request.getContextPath();//OA
String spath=request.getServletPath();//newsRe.do
String que=request.getQueryString();
  
String ref=request.getHeader("referer");//http://localhost:8080/OA/news.do?method=deploy&newsId=3&pagesize=6
String uri=request.getRequestURI();///OA/newsRe.do
String url=request.getRequestURL().toString();//http://localhost:8080/OA/newsRe.do  

分享到:
评论

相关推荐

    C# request获取参数.docx

    Request 对象提供了多种方式来获取请求参数,本文将详细介绍 Request.Params、Request、Request.QueryString、Request.Form 和 Request.Cookies 等对象的用法和区别。 一、Request.Params Request.Params 是所有 ...

    Java中Request请求转发详解

    Java中Request请求转发详解 Java中Request请求转发是指在Servlet中使用RequestDispatcher将请求转发到另一个Servlet或JSP页面,以实现请求的重定向或包含。在本文中,我们将通过示例代码详细介绍Java中Request请求...

    微信小程序开发:request请求后台获取不到data解决方法

    微信的request的post请求后台获取不到data(当初这个问题纠结了好久好久),原因是post传递的data是json格式而不是key,value的格式,所以获取不到相应的data就是post请求应为表单模式的data,微信小程序提供的data...

    获取request的参数

    对于`获取request的参数`这个主题,我们将主要关注查询参数和POST数据。 1. **URL查询参数**: 当用户在URL中传递参数时,这些参数会组成查询字符串,例如 `http://example.com/?param1=value1&param2=value2`。在...

    使用HttpServletRequestWrapper在filter修改request参数

    标题“使用HttpServletRequestWrapper在filter修改request参数”揭示了主要知识点,即如何在过滤器中通过自定义`HttpServletRequestWrapper` 子类来动态改变请求参数。这通常用于处理如数据验证、安全过滤、参数转换...

    java 获取request中的请求参数代码详解

    Java 获取 Request 中的请求参数代码详解 在 Web 开发中,获取 Request 中的请求参数是非常重要的一步。Java 提供了多种方式来获取 Request 中的请求参数,本文将详细介绍这些方法。 获取所有请求参数 在 Java 中...

    5、http请求的query参数1

    在上述示例中,通过Postman发送POST请求到 `/test` 路径,并在Body中填写表单数据,我们可以使用`$request->request`来获取POST参数,就像获取query参数一样。 了解`Request`对象的注入和使用是理解Symfony框架处理...

    request请求获取参数的实现方法(post和get两种方式)

    本文将详细介绍如何使用`HttpServletRequest`对象在Java Servlet中获取这两种方式下的请求参数。 首先,GET请求通常用于从客户端获取少量数据,这些数据会附加到URL后面。在HTML表单中,当`method`属性设置为`GET`...

    request获取url以及其参数

    综上所述,`HttpServletRequest`是处理HTTP请求的核心工具,它提供了丰富的API来获取URL、URL参数以及其他请求信息,如头信息、cookies等。熟练掌握这些方法,对于编写健壮的Java Web应用程序至关重要。在实际项目中...

    java修改请求参数

    通过这个接口,我们可以获取到请求参数,例如`getParameter()`和`getParameterMap()`方法。`getParameterMap()`返回一个`Map, String[]>`,其中键是参数名,值是该参数的所有值(因为同一个参数名可能对应多个值)。...

    TP5 Request 请求对象

    开发者可以通过这个对象轻松地获取请求参数、头信息、HTTP方法等关键信息,以便于实现业务逻辑。 首先,`Request`对象是通过依赖注入的方式提供的。在控制器方法中,我们可以直接声明`$request`作为参数,TP5会自动...

    java中对象的作用,如何获取Request对象

    确保正确配置后,你可以在Servlet的`doGet`或`doPost`方法中通过`HttpServletRequest`参数来获取Request对象,例如: ```java protected void doPost(HttpServletRequest request, HttpServletResponse response) ...

    UniApp中封装request网络请求包含GET、POST、PUT、DELETE等

    在这个封装中,我们为GET、POST、PUT和DELETE方法提供了统一的调用接口,并在`request`函数中处理了基础的请求配置,如URL前缀、数据序列化、添加认证头以及错误处理。`showLoading`和`loadingText`用于显示加载提示...

    SPRING MVC 的请求参数获取的几种方法

    SPRING MVC 请求参数获取的几种方法 SPRING MVC 框架中,获取请求参数是非常重要的一步,下面将介绍 SPRING MVC 中获取请求参数的几种方法。 1. 使用 @PathVariable 注解获取路径中传递参数 在 SPRING MVC 中,...

    c#Request关于Url分析

    本文将详细介绍如何使用`HttpRequest`对象来分析和获取URL的相关信息。 #### 1. `Request.Url`与`Request.RawUrl` - **`Request.Url`**:该属性返回一个`Uri`对象,表示客户端请求的完整URL。 - **示例**:如果...

    java遍历http请求request的所有参数实现方法

    在这个方法内,我们可以获取请求的所有参数: ```java public class RequestParameterServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response...

    Nginx服务器中使用lua获取get或post参数.docx

    首先,我们可以使用ngx.var.request_method获取当前请求的方法是GET还是POST,然后使用ngx.req.get_uri_args()或ngx.req.get_post_args()来获取请求参数。在GET请求中,我们可以直接使用ngx.req.get_uri_args()来...

    Spring MVC请求参数与响应结果全局加密和解密详解

    在本文中,我们将详细介绍Spring MVC请求参数与响应结果全局加密和解密的相关知识点,包括请求参数的加密和解密、响应结果的加密和解密、ContentType的处理等。 首先,让我们了解一下请求参数的加密和解密。为了...

Global site tag (gtag.js) - Google Analytics