类 ServletRequestContext

java.lang.Object
cn.taketoday.core.AttributeAccessorSupport
cn.taketoday.web.RequestContext
cn.taketoday.web.servlet.ServletRequestContext
所有已实现的接口:
cn.taketoday.core.AttributeAccessor, cn.taketoday.core.io.InputStreamSource, cn.taketoday.core.io.OutputStreamSource, HttpInputMessage, HttpMessage, HttpRequest, ServletIndicator, Serializable

public final class ServletRequestContext extends RequestContext implements ServletIndicator
Servlet environment implementation
从以下版本开始:
2.3.7
作者:
TODAY 2019-07-07 22:27
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • request

      private final HttpServletRequest request
    • response

      private final HttpServletResponse response
    • requestTimeMillis

      private final long requestTimeMillis
    • bodyUsed

      private boolean bodyUsed
    • headersWritten

      private boolean headersWritten
  • 构造器详细资料

  • 方法详细资料

    • getRequest

      public HttpServletRequest getRequest()
      指定者:
      getRequest 在接口中 ServletIndicator
    • getResponse

      public HttpServletResponse getResponse()
      指定者:
      getResponse 在接口中 ServletIndicator
    • getRequestTimeMillis

      public long getRequestTimeMillis()
      从类复制的说明: RequestContext
      Get start handling this request time millis
      指定者:
      getRequestTimeMillis 在类中 RequestContext
      返回:
      start handling this request time millis
    • initId

      @Nullable protected String initId()
      从类复制的说明: RequestContext
      Obtain the request id to use, or null in which case the Object identity of this request instance is used.
      覆盖:
      initId 在类中 RequestContext
    • getScheme

      public String getScheme()
      从类复制的说明: RequestContext
      Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.
      指定者:
      getScheme 在类中 RequestContext
      返回:
      a String containing the name of the scheme used to make this request
    • getServerName

      public String getServerName()
      从类复制的说明: RequestContext
      Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the Host header value, if any, or the resolved server name, or the server IP address.
      指定者:
      getServerName 在类中 RequestContext
      返回:
      a String containing the name of the server
    • getServerPort

      public int getServerPort()
      从类复制的说明: RequestContext
      Returns the port number to which the request was sent. It is the value of the part after ":" in the Host header value, if any, or the server port where the client connection was accepted on.
      指定者:
      getServerPort 在类中 RequestContext
      返回:
      an integer specifying the port number
    • doGetContextPath

      protected String doGetContextPath()
      覆盖:
      doGetContextPath 在类中 RequestContext
    • doGetRequestPath

      protected RequestPath doGetRequestPath()
      覆盖:
      doGetRequestPath 在类中 RequestContext
    • nativeRequest

      public <T> T nativeRequest()
      从类复制的说明: RequestContext
      Native request eg: HttpServletRequest
      指定者:
      nativeRequest 在类中 RequestContext
    • unwrapRequest

      public <T> T unwrapRequest(Class<T> requestClass)
      指定者:
      unwrapRequest 在类中 RequestContext
      参数:
      requestClass - wrapped request class
      返回:
      returns null indicated that not a requestClass
    • nativeResponse

      public <T> T nativeResponse()
    • doGetOutputStream

      protected OutputStream doGetOutputStream() throws IOException
      从类复制的说明: RequestContext
      template method for get OutputStream
      指定者:
      doGetOutputStream 在类中 RequestContext
      抛出:
      IOException
    • doGetInputStream

      protected InputStream doGetInputStream() throws IOException
      指定者:
      doGetInputStream 在类中 RequestContext
      抛出:
      IOException
    • doGetWriter

      protected PrintWriter doGetWriter() throws IOException
      从类复制的说明: RequestContext
      template method for get writer
      覆盖:
      doGetWriter 在类中 RequestContext
      抛出:
      IOException
    • doGetReader

      public BufferedReader doGetReader() throws IOException
      从类复制的说明: RequestContext
      template method for get reader
      覆盖:
      doGetReader 在类中 RequestContext
      抛出:
      IOException
    • doGetRequestURI

      public String doGetRequestURI()
      指定者:
      doGetRequestURI 在类中 RequestContext
    • getRequestURL

      public String getRequestURL()
      从类复制的说明: RequestContext
      The 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

      public String doGetQueryString()
      指定者:
      doGetQueryString 在类中 RequestContext
    • doGetCookies

      protected HttpCookie[] doGetCookies()
      指定者:
      doGetCookies 在类中 RequestContext
      返回:
      an array of all the Cookies included with this request,or RequestContext.EMPTY_COOKIES if the request has no cookies
    • doGetParameters

      public Map<String,String[]> doGetParameters()
      覆盖:
      doGetParameters 在类中 RequestContext
    • getParameterNames

      public Iterator<String> getParameterNames()
      从类复制的说明: RequestContext
      Returns an Iterator of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Iterator.
      覆盖:
      getParameterNames 在类中 RequestContext
      返回:
      an Iterator of String objects, each String containing the name of a request parameter; or an empty Iterator if the request has no parameters
    • getParameters

      public String[] getParameters(String name)
      从类复制的说明: RequestContext
      Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

      If the parameter has a single value, the array has a length of 1.

      覆盖:
      getParameters 在类中 RequestContext
      参数:
      name - a String containing the name of the parameter whose value is requested
      返回:
      an array of String objects containing the parameter's values
      另请参阅:
    • getParameter

      public String getParameter(String name)
      从类复制的说明: RequestContext
      Returns the value of a request parameter as a String, or null if 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() or RequestContext.getReader() can interfere with the execution of this method.

      覆盖:
      getParameter 在类中 RequestContext
      参数:
      name - a String specifying the name of the parameter
      返回:
      a String representing the single value of the parameter
      另请参阅:
    • doGetMethod

      protected String doGetMethod()
      指定者:
      doGetMethod 在类中 RequestContext
    • getRemoteAddress

      public String getRemoteAddress()
      从类复制的说明: RequestContext
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      指定者:
      getRemoteAddress 在类中 RequestContext
      返回:
      a String containing the IP address of the client that sent the request
    • getContentLength

      public long getContentLength()
      从类复制的说明: RequestContext
      Returns 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

      public String getContentType()
      从类复制的说明: RequestContext
      Returns the MIME type of the body of the request, or null if the type is not known.
      指定者:
      getContentType 在类中 RequestContext
      返回:
      a String containing the name of the MIME type of the request, or null if the type is not known
    • setContentType

      public void setContentType(String contentType)
      从类复制的说明: RequestContext
      Sets 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 before getWriter is 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 getWriter has 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-Type header is used.

      覆盖:
      setContentType 在类中 RequestContext
      参数:
      contentType - a String specifying the MIME type of the content
    • getResponseContentType

      public String getResponseContentType()
      从类复制的说明: RequestContext
      Returns the content type used for the MIME body sent in this response. The content type proper must have been specified using RequestContext.setContentType(java.lang.String) before the response is committed. If no content type has been specified, this method returns null.
      覆盖:
      getResponseContentType 在类中 RequestContext
      返回:
      a String specifying the content type, for example, text/html; charset=UTF-8, or null
      另请参阅:
    • setContentLength

      public void setContentLength(long length)
      从类复制的说明: RequestContext
      Sets 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()
      从类复制的说明: RequestContext
      Returns 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

      protected Locale doGetLocale()
      覆盖:
      doGetLocale 在类中 RequestContext
    • reset

      public void reset()
      从类复制的说明: RequestContext
      Clears any data that exists in the buffer as well as the status code, headers. The state of calling RequestContext.getWriter() or RequestContext.getOutputStream() is also cleared. It is legal, for instance, to call RequestContext.getWriter(), reset() and then RequestContext.getOutputStream(). If RequestContext.getWriter() or RequestContext.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 an IllegalStateException.
      覆盖:
      reset 在类中 RequestContext
    • sendRedirect

      public void sendRedirect(String location) throws IOException
      从类复制的说明: RequestContext
      Sends 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)
      从类复制的说明: RequestContext
      Sets 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()
      从类复制的说明: RequestContext
      Gets the current status code of this response.
      指定者:
      getStatus 在类中 RequestContext
      返回:
      the current status code of this response
    • createRequestHeaders

      protected HttpHeaders createRequestHeaders()
      从类复制的说明: RequestContext
      template method for create request http-headers
      指定者:
      createRequestHeaders 在类中 RequestContext
      从以下版本开始:
      3.0
    • sendError

      public void sendError(int sc) throws IOException
      从类复制的说明: RequestContext
      Sends 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 page

      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 code
      抛出:
      IOException - If an input or output exception occurs
    • sendError

      public void sendError(int sc, @Nullable String msg) throws IOException
      从类复制的说明: RequestContext

      Sends 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 code
      msg - the descriptive message
      抛出:
      IOException - If an input or output exception occurs
    • createMultipartRequest

      protected MultipartRequest createMultipartRequest()
      从类复制的说明: RequestContext
      create MultipartRequest
      指定者:
      createMultipartRequest 在类中 RequestContext
    • createAsyncWebRequest

      protected AsyncWebRequest createAsyncWebRequest()
      指定者:
      createAsyncWebRequest 在类中 RequestContext
    • writeHeaders

      public void writeHeaders()
      从类复制的说明: RequestContext
      write headers to response
      覆盖:
      writeHeaders 在类中 RequestContext
    • flush

      public void flush() throws IOException
      从类复制的说明: RequestContext
      Forces 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

      protected void postRequestCompleted(@Nullable Throwable notHandled)
      覆盖:
      postRequestCompleted 在类中 RequestContext
    • setAttribute

      public void setAttribute(String name, Object value)
      指定者:
      setAttribute 在接口中 cn.taketoday.core.AttributeAccessor
      覆盖:
      setAttribute 在类中 cn.taketoday.core.AttributeAccessorSupport
    • removeAttribute

      public Object removeAttribute(String name)
      指定者:
      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

      public Object getAttribute(String name)
      指定者:
      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

      public boolean hasAttribute(String name)
      指定者:
      hasAttribute 在接口中 cn.taketoday.core.AttributeAccessor
      覆盖:
      hasAttribute 在类中 cn.taketoday.core.AttributeAccessorSupport
    • getAttributeNames

      public String[] getAttributeNames()
      指定者:
      getAttributeNames 在接口中 cn.taketoday.core.AttributeAccessor
      覆盖:
      getAttributeNames 在类中 cn.taketoday.core.AttributeAccessorSupport
    • attributeNames

      public Iterator<String> attributeNames()
      指定者:
      attributeNames 在接口中 cn.taketoday.core.AttributeAccessor
      覆盖:
      attributeNames 在类中 cn.taketoday.core.AttributeAccessorSupport