public class RequestUtils extends Object
| Constructor and Description |
|---|
RequestUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.springframework.util.MultiValueMap<String,String> |
getQueryStringParameters(javax.servlet.http.HttpServletRequest request)
Returns a
MultiValueMap of the parameters parsed from the request's query string. |
static String |
getQueryStringParameterValue(javax.servlet.http.HttpServletRequest request,
String parameterName)
Returns the value parsed from the request's query string for the given parameter name.
|
static List<String> |
getQueryStringParameterValues(javax.servlet.http.HttpServletRequest request,
String parameterName)
Returns a
List of values parsed from the request's query string for the given parameter
name. |
static String |
getRemoteAddress()
Returns remote address by using
HttpServletRequest from RequestContextHolder |
static String |
getRemoteAddress(javax.servlet.http.HttpServletRequest request)
Returns remote address
|
static void |
logRequestHeadersAndQueryParams(javax.servlet.http.HttpServletRequest request,
org.slf4j.Logger logger)
Posts an informational message the the supplied
Logger showing the request headers and
query parameters |
public static String getRemoteAddress(javax.servlet.http.HttpServletRequest request)
request - contains the details of http requestpublic static String getRemoteAddress()
HttpServletRequest from RequestContextHolderpublic static void logRequestHeadersAndQueryParams(javax.servlet.http.HttpServletRequest request,
org.slf4j.Logger logger)
Logger showing the request headers and
query parameters
For example:
##### HEADERS ######## X-Requested-By = ambari ... Accept-Encoding = gzip, deflate Accept-Language = en-US,en;q=0.9 ###################### ##### PARAMETERS ##### _ = 1543700737939 ######################
request - the HttpServletRequest to loglogger - the Loggerpublic static org.springframework.util.MultiValueMap<String,String> getQueryStringParameters(javax.servlet.http.HttpServletRequest request)
MultiValueMap of the parameters parsed from the request's query string. The
returned map will not contain any parameters that may be in the body of the request as form data.
This implementation manually parses the query string rather than use ServletRequest.getParameterValues(String)
so that the message body remains intact and available. Calling ServletRequest.getParameterValues(String)
could interfere with processing the body of this request later since the body is parsed to find
any form parameters.
request - the HttpServletRequestpublic static List<String> getQueryStringParameterValues(javax.servlet.http.HttpServletRequest request, String parameterName)
List of values parsed from the request's query string for the given parameter
name.request - the HttpServletRequestnull if the
requested parameter is not presentgetQueryStringParameters(HttpServletRequest)public static String getQueryStringParameterValue(javax.servlet.http.HttpServletRequest request, String parameterName)
If more than one value for the given parameter name is found, the first value will be retured.
request - the HttpServletRequestnull if the
requested parameter is not presentgetQueryStringParameters(HttpServletRequest)Copyright © 2022 Apache Software Foundation. All rights reserved.