类 ContentCachingRequestWrapper
- java.lang.Object
- javax.servlet.ServletRequestWrapper
- javax.servlet.http.HttpServletRequestWrapper
- org.springframework.web.util.ContentCachingRequestWrapper
- 所有已实现的接口:
HttpServletRequest
,ServletRequest
public class ContentCachingRequestWrapper extends HttpServletRequestWrapper
HttpServletRequest
wrapper that caches all content read from the input stream and reader, and allows this content to be retrieved via abyte array
.Used e.g. by
AbstractRequestLoggingFilter
.- 从以下版本开始:
- 4.1.3
- 作者:
- Juergen Hoeller, Brian Clozel
- 另请参阅:
ContentCachingResponseWrapper
字段概要
从接口继承的字段 javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
构造器概要
构造器 构造器 说明 ContentCachingRequestWrapper(HttpServletRequest request)
Create a new ContentCachingRequestWrapper for the given servlet request.ContentCachingRequestWrapper(HttpServletRequest request, int contentCacheLimit)
Create a new ContentCachingRequestWrapper for the given servlet request.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 String
getCharacterEncoding()
byte[]
getContentAsByteArray()
Return the cached request content as a byte array.ServletInputStream
getInputStream()
String
getParameter(String name)
Map<String,String[]>
getParameterMap()
Enumeration<String>
getParameterNames()
String[]
getParameterValues(String name)
BufferedReader
getReader()
protected void
handleContentOverflow(int contentCacheLimit)
Template method for handling a content overflow: specifically, a request body being read that exceeds the specified content cache limit.从类继承的方法 javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade
从类继承的方法 javax.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 javax.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
构造器详细资料
ContentCachingRequestWrapper
public ContentCachingRequestWrapper(HttpServletRequest request)
Create a new ContentCachingRequestWrapper for the given servlet request.- 参数:
request
- the original servlet request
ContentCachingRequestWrapper
public ContentCachingRequestWrapper(HttpServletRequest request, int contentCacheLimit)
Create a new ContentCachingRequestWrapper for the given servlet request.- 参数:
request
- the original servlet requestcontentCacheLimit
- the maximum number of bytes to cache per request- 从以下版本开始:
- 4.3.6
- 另请参阅:
handleContentOverflow(int)
方法详细资料
getInputStream
public ServletInputStream getInputStream() throws IOException
- 指定者:
getInputStream
在接口中ServletRequest
- 覆盖:
getInputStream
在类中ServletRequestWrapper
- 抛出:
IOException
getCharacterEncoding
public String getCharacterEncoding()
getReader
public BufferedReader getReader() throws IOException
- 指定者:
getReader
在接口中ServletRequest
- 覆盖:
getReader
在类中ServletRequestWrapper
- 抛出:
IOException
getParameter
public String getParameter(String name)
- 指定者:
getParameter
在接口中ServletRequest
- 覆盖:
getParameter
在类中ServletRequestWrapper
getParameterMap
public Map<String,String[]> getParameterMap()
- 指定者:
getParameterMap
在接口中ServletRequest
- 覆盖:
getParameterMap
在类中ServletRequestWrapper
getParameterNames
public Enumeration<String> getParameterNames()
- 指定者:
getParameterNames
在接口中ServletRequest
- 覆盖:
getParameterNames
在类中ServletRequestWrapper
getParameterValues
public String[] getParameterValues(String name)
- 指定者:
getParameterValues
在接口中ServletRequest
- 覆盖:
getParameterValues
在类中ServletRequestWrapper
getContentAsByteArray
public byte[] getContentAsByteArray()
Return the cached request content as a byte array.The returned array will never be larger than the content cache limit.
handleContentOverflow
protected void handleContentOverflow(int contentCacheLimit)
Template method for handling a content overflow: specifically, a request body being read that exceeds the specified content cache limit.The default implementation is empty. Subclasses may override this to throw a payload-too-large exception or the like.
- 参数:
contentCacheLimit
- the maximum number of bytes to cache per request which has just been exceeded- 从以下版本开始:
- 4.3.6
- 另请参阅:
ContentCachingRequestWrapper(HttpServletRequest, int)