Last active
February 7, 2023 10:26
-
-
Save Crydust/e4e93dbc6886c8d2f02e0ce00b856732 to your computer and use it in GitHub Desktop.
log HttpServletRequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sb.append("*** request.getMethod() = ").append(request.getMethod()).append("\n"); | |
sb.append("*** request.getContextPath() = ").append(request.getContextPath()).append("\n"); | |
sb.append("*** request.getRequestURI() = ").append(request.getRequestURI()).append("\n"); | |
sb.append("*** request.getServletPath() = ").append(request.getServletPath()).append("\n"); | |
sb.append("*** request.getPathInfo() = ").append(request.getPathInfo()).append("\n"); | |
final ArrayList<String> headerNames = Collections.list(request.getHeaderNames()); | |
for (final String headerName : headerNames) { | |
final ArrayList<String> headers = Collections.list(request.getHeaders(headerName)); | |
for (int i = 0; i < headers.size(); i++) { | |
final String header = headers.get(i); | |
sb.append("*** Collections.list(request.getHeaders(\"").append(headerName).append("\")).get(").append(i).append(") = ").append(header).append("\n"); | |
} | |
} | |
final Map<String, String[]> parameterMap = request.getParameterMap(); | |
for (final String key : parameterMap.keySet()) { | |
final String[] values = parameterMap.get(key); | |
for (int i = 0; i < values.length; i++) { | |
final String value = values[i]; | |
sb.append("*** request.getParameterMap().get(\"").append(key).append("\")[").append(i).append("] = ").append(value).append("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment