类 ServletRequestContext
- 所有已实现的接口:
cn.taketoday.core.AttributeAccessor,cn.taketoday.core.io.InputStreamSource,cn.taketoday.core.io.OutputStreamSource,HttpInputMessage,HttpMessage,HttpRequest,ServletIndicator,Serializable
- 从以下版本开始:
- 2.3.7
- 作者:
- TODAY 2019-07-07 22:27
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private static final classSimple wrapper around the defaultRequestPathimplementation that supports a servletPath as an additional prefix to be omitted fromServletRequestContext.ServletRequestPath.pathWithinApplication(). -
字段概要
字段修饰符和类型字段说明private booleanprivate booleanprivate final HttpServletRequestprivate final longprivate final HttpServletResponseprivate static final long从类继承的字段 cn.taketoday.web.RequestContext
applicationContext, asyncWebRequest, bindingContext, contextPath, cookies, corsRequestFlag, EMPTY_COOKIES, httpMethod, inputStream, locale, lookupPath, method, multipartFlag, multipartRequest, notModified, outputStream, parameters, pathWithinApplication, preFlightRequestFlag, queryString, reader, redirectModel, requestDestructionCallbacks, requestHeaders, requestPath, requestURI, responseContentType, responseCookies, responseHeaders, SCOPE_REQUEST, SCOPE_SESSION, uri, webAsyncManager, writer从类继承的字段 cn.taketoday.core.AttributeAccessorSupport
attributes -
构造器概要
构造器构造器说明ServletRequestContext(cn.taketoday.context.ApplicationContext context, HttpServletRequest request, HttpServletResponse response) -
方法概要
修饰符和类型方法说明voidprotected AsyncWebRequestprotected MultipartRequestcreate MultipartRequestprotected HttpHeaderstemplate method for create request http-headersprotected Stringprotected HttpCookie[]protected InputStreamprotected Localeprotected Stringprotected OutputStreamtemplate method for get OutputStreamtemplate method for get readerprotected RequestPathprotected PrintWritertemplate method for get writervoidflush()Forces any content in the buffer to be written to the client.getAttribute(String name) String[]longReturns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.Returns the MIME type of the body of the request, ornullif the type is not known.getParameter(String name) Returns the value of a request parameter as aString, ornullif the parameter does not exist.Returns anIteratorofStringobjects containing the names of the parameters contained in this request.String[]getParameters(String name) Returns an array ofStringobjects containing all of the values the given request parameter has, ornullif the parameter does not exist.Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.longGet start handling this request time millisThe returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.Returns the content type used for the MIME body sent in this response.Returns the name of the scheme used to make this request, for example,http,https, orftp.Returns the host name of the server to which the request was sent.intReturns the port number to which the request was sent.intGets the current status code of this response.booleanhasAttribute(String name) booleanprotected StringinitId()Obtain the request id to use, ornullin which case the Object identity of this request instance is used.booleanReturns a boolean indicating if the response has been committed.<T> TNative request eg: HttpServletRequest<T> Tprotected voidpostRequestCompleted(Throwable notHandled) removeAttribute(String name) voidreset()Clears any data that exists in the buffer as well as the status code, headers.voidsendError(int sc) Sends an error response to the client using the specified status code and clears the buffer.voidSends an error response to the client using the specified status and clears the buffer.voidsendRedirect(String location) Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.voidsetAttribute(String name, Object value) voidsetContentLength(long length) Sets the length of the content body in the response , this method sets the HTTP Content-Length header.voidsetContentType(String contentType) Sets the content type of the response being sent to the client, if the response has not been committed yet.voidsetStatus(int sc) Sets the status code for this response.<T> TunwrapRequest(Class<T> requestClass) voidwrite headers to response从类继承的方法 cn.taketoday.web.RequestContext
addCookie, addCookie, asHttpOutputMessage, binding, checkNotModified, checkNotModified, checkNotModified, createResponseHeaders, getApplicationContext, getAsyncManager, getAsyncWebRequest, getBinding, getBody, getContextPath, getCookie, getCookies, getHeaders, getInputRedirectModel, getInputRedirectModel, getInputStream, getLocale, getLookupPath, getMatchingMetadata, getMethod, getMethodValue, getMultipartRequest, getOutputStream, getParameters, getPort, getQueryString, getReader, getRequestId, getRequestPath, getRequestProcessingTime, getRequestURI, getURI, getWriter, hasBinding, hasMatchingMetadata, isConcurrentHandlingStarted, isCorsRequest, isMultipart, isNotModified, isPreFlightRequest, matchingMetadata, mergeToResponse, postGetParameters, registerRequestDestructionCallback, registerRequestDestructionCallback, removeCookie, removeRequestDestructionCallback, requestCompleted, requestCompleted, requestHeaders, responseCookies, responseHeaders, sendError, sendError, setBinding, setContentType, setMatchingMetadata, setStatus, setWebAsyncManagerFactory, toString从类继承的方法 cn.taketoday.core.AttributeAccessorSupport
computeAttribute, copyAttributesFrom, createAttributes, equals, getAttributes, hashCode从接口继承的方法 cn.taketoday.core.AttributeAccessor
computeAttribute, copyAttributesFrom, getAttributes从接口继承的方法 cn.taketoday.core.io.InputStreamSource
getReader, readableChannel从接口继承的方法 cn.taketoday.core.io.OutputStreamSource
writableChannel
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
request
-
response
-
requestTimeMillis
private final long requestTimeMillis -
bodyUsed
private boolean bodyUsed -
headersWritten
private boolean headersWritten
-
-
构造器详细资料
-
ServletRequestContext
public ServletRequestContext(cn.taketoday.context.ApplicationContext context, HttpServletRequest request, HttpServletResponse response)
-
-
方法详细资料
-
getRequest
- 指定者:
getRequest在接口中ServletIndicator
-
getResponse
- 指定者:
getResponse在接口中ServletIndicator
-
getRequestTimeMillis
public long getRequestTimeMillis()从类复制的说明:RequestContextGet start handling this request time millis- 指定者:
getRequestTimeMillis在类中RequestContext- 返回:
- start handling this request time millis
-
initId
从类复制的说明:RequestContextObtain the request id to use, ornullin which case the Object identity of this request instance is used.- 覆盖:
initId在类中RequestContext
-
getScheme
从类复制的说明:RequestContextReturns the name of the scheme used to make this request, for example,http,https, orftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.- 指定者:
getScheme在类中RequestContext- 返回:
- a
Stringcontaining the name of the scheme used to make this request
-
getServerName
从类复制的说明:RequestContextReturns the host name of the server to which the request was sent. It is the value of the part before ":" in theHostheader value, if any, or the resolved server name, or the server IP address.- 指定者:
getServerName在类中RequestContext- 返回:
- a
Stringcontaining the name of the server
-
getServerPort
public int getServerPort()从类复制的说明:RequestContextReturns the port number to which the request was sent. It is the value of the part after ":" in theHostheader value, if any, or the server port where the client connection was accepted on.- 指定者:
getServerPort在类中RequestContext- 返回:
- an integer specifying the port number
-
doGetContextPath
- 覆盖:
doGetContextPath在类中RequestContext
-
doGetRequestPath
- 覆盖:
doGetRequestPath在类中RequestContext
-
nativeRequest
public <T> T nativeRequest()从类复制的说明:RequestContextNative request eg: HttpServletRequest- 指定者:
nativeRequest在类中RequestContext
-
unwrapRequest
- 指定者:
unwrapRequest在类中RequestContext- 参数:
requestClass- wrapped request class- 返回:
- returns
nullindicated that not a requestClass
-
nativeResponse
public <T> T nativeResponse() -
doGetOutputStream
从类复制的说明:RequestContexttemplate method for get OutputStream- 指定者:
doGetOutputStream在类中RequestContext- 抛出:
IOException
-
doGetInputStream
- 指定者:
doGetInputStream在类中RequestContext- 抛出:
IOException
-
doGetWriter
从类复制的说明:RequestContexttemplate method for get writer- 覆盖:
doGetWriter在类中RequestContext- 抛出:
IOException
-
doGetReader
从类复制的说明:RequestContexttemplate method for get reader- 覆盖:
doGetReader在类中RequestContext- 抛出:
IOException
-
doGetRequestURI
- 指定者:
doGetRequestURI在类中RequestContext
-
getRequestURL
从类复制的说明:RequestContextThe returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.- 覆盖:
getRequestURL在类中RequestContext- 返回:
- A URL
-
doGetQueryString
- 指定者:
doGetQueryString在类中RequestContext
-
doGetCookies
- 指定者:
doGetCookies在类中RequestContext- 返回:
- an array of all the Cookies included with this request,or
RequestContext.EMPTY_COOKIESif the request has no cookies
-
doGetParameters
- 覆盖:
doGetParameters在类中RequestContext
-
getParameterNames
从类复制的说明:RequestContextReturns anIteratorofStringobjects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an emptyIterator.- 覆盖:
getParameterNames在类中RequestContext- 返回:
- an
IteratorofStringobjects, eachStringcontaining the name of a request parameter; or an emptyIteratorif the request has no parameters
-
getParameters
从类复制的说明:RequestContextReturns an array ofStringobjects containing all of the values the given request parameter has, ornullif the parameter does not exist.If the parameter has a single value, the array has a length of 1.
- 覆盖:
getParameters在类中RequestContext- 参数:
name- aStringcontaining the name of the parameter whose value is requested- 返回:
- an array of
Stringobjects containing the parameter's values - 另请参阅:
-
getParameter
从类复制的说明:RequestContextReturns the value of a request parameter as aString, ornullif the parameter does not exist. Request parameters are extra information sent with the request. Parameters are contained in the query string or posted form data.You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use
RequestContext.getParameters(String).If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by
parameters(String).If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via
RequestContext.getInputStream()orRequestContext.getReader()can interfere with the execution of this method.- 覆盖:
getParameter在类中RequestContext- 参数:
name- aStringspecifying the name of the parameter- 返回:
- a
Stringrepresenting the single value of the parameter - 另请参阅:
-
doGetMethod
- 指定者:
doGetMethod在类中RequestContext
-
getRemoteAddress
从类复制的说明:RequestContextReturns the Internet Protocol (IP) address of the client or last proxy that sent the request.- 指定者:
getRemoteAddress在类中RequestContext- 返回:
- a
Stringcontaining the IP address of the client that sent the request
-
getContentLength
public long getContentLength()从类复制的说明:RequestContextReturns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.- 指定者:
getContentLength在类中RequestContext- 返回:
- a long containing the length of the request body or -1L if the length is not known
-
getContentType
从类复制的说明:RequestContextReturns the MIME type of the body of the request, ornullif the type is not known.- 指定者:
getContentType在类中RequestContext- 返回:
- a
Stringcontaining the name of the MIME type of the request, or null if the type is not known
-
setContentType
从类复制的说明:RequestContextSets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example,text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called beforegetWriteris called.This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after
getWriterhas been called or after the response has been committed.Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the
Content-Typeheader is used.- 覆盖:
setContentType在类中RequestContext- 参数:
contentType- aStringspecifying the MIME type of the content
-
getResponseContentType
从类复制的说明:RequestContextReturns the content type used for the MIME body sent in this response. The content type proper must have been specified usingRequestContext.setContentType(java.lang.String)before the response is committed. If no content type has been specified, this method returns null.- 覆盖:
getResponseContentType在类中RequestContext- 返回:
- a
Stringspecifying the content type, for example,text/html; charset=UTF-8, or null - 另请参阅:
-
setContentLength
public void setContentLength(long length) 从类复制的说明:RequestContextSets the length of the content body in the response , this method sets the HTTP Content-Length header.- 覆盖:
setContentLength在类中RequestContext- 参数:
length- an long specifying the length of the content being returned to the client; sets the Content-Length header
-
isCommitted
public boolean isCommitted()从类复制的说明:RequestContextReturns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.- 指定者:
isCommitted在类中RequestContext- 返回:
- a boolean indicating if the response has been committed
- 另请参阅:
-
doGetLocale
- 覆盖:
doGetLocale在类中RequestContext
-
reset
public void reset()从类复制的说明:RequestContextClears any data that exists in the buffer as well as the status code, headers. The state of callingRequestContext.getWriter()orRequestContext.getOutputStream()is also cleared. It is legal, for instance, to callRequestContext.getWriter(), reset() and thenRequestContext.getOutputStream(). IfRequestContext.getWriter()orRequestContext.getOutputStream()have been called before this method, then the corresponding returned Writer or OutputStream will be staled and the behavior of using the stale object is undefined. If the response has been committed, this method throws anIllegalStateException.- 覆盖:
reset在类中RequestContext
-
sendRedirect
从类复制的说明:RequestContextSends a temporary redirect response to the client using the specified redirect location URL and clears the buffer. The buffer will be replaced with the data set by this method. Calling this method sets the status code to 302 (Found). This method can accept relative URLs;the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. If the location is relative with two leading '/' the container interprets it as a network-path reference (see RFC 3986: Uniform Resource Identifier (URI): Generic Syntax, section 4.2 "Relative Reference").If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
- 指定者:
sendRedirect在类中RequestContext- 参数:
location- the redirect location URL- 抛出:
IOException- If an input or output exception occurs
-
setStatus
public void setStatus(int sc) 从类复制的说明:RequestContextSets the status code for this response.This method is used to set the return status code when there is no error .
This method preserves any cookies and other response headers.
Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container specific.
- 指定者:
setStatus在类中RequestContext- 参数:
sc- the status code
-
getStatus
public int getStatus()从类复制的说明:RequestContextGets the current status code of this response.- 指定者:
getStatus在类中RequestContext- 返回:
- the current status code of this response
-
createRequestHeaders
从类复制的说明:RequestContexttemplate method for create request http-headers- 指定者:
createRequestHeaders在类中RequestContext- 从以下版本开始:
- 3.0
-
sendError
从类复制的说明:RequestContextSends an error response to the client using the specified status code and clears the buffer. The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back the error pageIf the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
- 指定者:
sendError在类中RequestContext- 参数:
sc- the error status code- 抛出:
IOException- If an input or output exception occurs
-
sendError
从类复制的说明:RequestContextSends an error response to the client using the specified status and clears the buffer. The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html". The caller is not responsible for escaping or re-encoding the message to ensure it is safe with respect to the current response encoding and content type. This aspect of safety is the responsibility of the container, as it is generating the error page containing the message. The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response.
If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter and the msg parameter will be ignored.
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
- 指定者:
sendError在类中RequestContext- 参数:
sc- the error status codemsg- the descriptive message- 抛出:
IOException- If an input or output exception occurs
-
createMultipartRequest
从类复制的说明:RequestContextcreate MultipartRequest- 指定者:
createMultipartRequest在类中RequestContext
-
createAsyncWebRequest
- 指定者:
createAsyncWebRequest在类中RequestContext
-
writeHeaders
public void writeHeaders()从类复制的说明:RequestContextwrite headers to response- 覆盖:
writeHeaders在类中RequestContext
-
flush
从类复制的说明:RequestContextForces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written. Ensure that the headers and the content of the response are written out.After the first flush, headers can no longer be changed. Only further content writing and content flushing is possible.
- 覆盖:
flush在类中RequestContext- 抛出:
IOException- if the act of flushing the buffer cannot be completed.- 另请参阅:
-
postRequestCompleted
- 覆盖:
postRequestCompleted在类中RequestContext
-
setAttribute
- 指定者:
setAttribute在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
setAttribute在类中cn.taketoday.core.AttributeAccessorSupport
-
removeAttribute
- 指定者:
removeAttribute在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
removeAttribute在类中cn.taketoday.core.AttributeAccessorSupport
-
clearAttributes
public void clearAttributes()- 指定者:
clearAttributes在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
clearAttributes在类中cn.taketoday.core.AttributeAccessorSupport
-
getAttribute
- 指定者:
getAttribute在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
getAttribute在类中cn.taketoday.core.AttributeAccessorSupport
-
hasAttributes
public boolean hasAttributes()- 指定者:
hasAttributes在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
hasAttributes在类中cn.taketoday.core.AttributeAccessorSupport
-
hasAttribute
- 指定者:
hasAttribute在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
hasAttribute在类中cn.taketoday.core.AttributeAccessorSupport
-
getAttributeNames
- 指定者:
getAttributeNames在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
getAttributeNames在类中cn.taketoday.core.AttributeAccessorSupport
-
attributeNames
- 指定者:
attributeNames在接口中cn.taketoday.core.AttributeAccessor- 覆盖:
attributeNames在类中cn.taketoday.core.AttributeAccessorSupport
-