public class RepeatRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper
该类主要为解决 HttpServletRequest 中 inputStream 流只能被读取一次问题
在处理表单请求时需要注意, 如果带有文件将会调用 HttpServletRequest.getParts() 拿到文件域,
最终会调用 Request.getParts() 方法, 核心为 getParts() 方法中的 parseParts(boolean) 方法,
在 parseParts(boolean) 方法中将会使用 FileUploadBase.parseRequest(RequestContext) 方法进行解析文件,
在 parseRequest(RequestContext) 方法中取出输入流, 所以如果为非 json 请求时不进行任何操作
Warning: 在提前使用 getInputStream() 方法时依然需要谨慎使用
(建议提前使用 RequestUtils.isJsonRequest(HttpServletRequest)) 判断该请求是否为 json 请求
| 构造器和说明 |
|---|
RepeatRequestWrapper(javax.servlet.http.HttpServletRequest request)
Constructs a request object wrapping the given request.
|
| 限定符和类型 | 方法和说明 |
|---|---|
javax.servlet.ServletInputStream |
getInputStream() |
BufferedReader |
getReader() |
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradegetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsyncpublic RepeatRequestWrapper(javax.servlet.http.HttpServletRequest request)
throws IOException
request - The request to wrapIOException - If the request is nullpublic BufferedReader getReader() throws IOException
getReader 在接口中 javax.servlet.ServletRequestgetReader 在类中 javax.servlet.ServletRequestWrapperIOExceptionpublic javax.servlet.ServletInputStream getInputStream()
throws IOException
getInputStream 在接口中 javax.servlet.ServletRequestgetInputStream 在类中 javax.servlet.ServletRequestWrapperIOExceptionCopyright © 2021 HaiChuang Inc.. All rights reserved.