HttpServletResponseWrapper (Java EE 5)

Java EE API


javax.servlet.http Class HttpServletResponseWrapper

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
All Implemented Interfaces:
HttpServletResponse, ServletResponse

public class HttpServletResponseWrapper
extends ServletResponseWrapper
implements HttpServletResponse


提供 HttpServletResponse 接口的便捷实现,希望根据 Servlet 适配响应的开发人员可以子类化该接口。此类实现 Wrapper 或 Decorator 模式。默认情况下,方法通过包装的响应对象调用。
英文文档:

Provides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.

Since:
v 2.3
Author:
Various
See Also:
HttpServletResponse

Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
 
Constructor Summary
 
Method Summary
 void
 void
 void
 void
 boolean
 String
 String
 String
 String
 void
 void
 void
 void
 void
 void
 void
 void
 
Methods inherited from class javax.servlet.ServletResponseWrapper
 
Methods inherited from class java.lang.Object
 
Methods inherited from interface javax.servlet.ServletResponse
 

Constructor Detail

public HttpServletResponseWrapper(HttpServletResponse response)
构造包装给定响应的响应适配器。
ThrowsIllegalArgumentException: 如果 response 为 null
英文文档:

HttpServletResponseWrapper

public HttpServletResponseWrapper(HttpServletResponse response)
Constructs a response adaptor wrapping the given response.

Throws:
IllegalArgumentException - if the response is null

Method Detail

public void addCookie(Cookie cookie)
此方法的默认行为是对包装的响应对象调用 addCookie(Cookie cookie)。
英文文档:

addCookie

public void addCookie(Cookie cookie)
The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object.

Specified by:
addCookie in interface HttpServletResponse
Parameters:
cookie - the Cookie to return to the client

public boolean containsHeader(String name)
此方法的默认行为是对包装的响应对象调用 containsHeader(String name)。
英文文档:

containsHeader

public boolean containsHeader(String name)
The default behavior of this method is to call containsHeader(String name) on the wrapped response object.

Specified by:
containsHeader in interface HttpServletResponse
Parameters:
name - the header name
Returns:
true if the named response header has already been set; false otherwise

public String encodeURL(String url)
此方法的默认行为是对包装的响应对象调用 encodeURL(String url)。
英文文档:

encodeURL

public String encodeURL(String url)
The default behavior of this method is to call encodeURL(String url) on the wrapped response object.

Specified by:
encodeURL in interface HttpServletResponse
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

public String encodeRedirectURL(String url)
此方法的默认行为是返回对包装的响应对象调用 encodeRedirectURL(String url) 的结果。
英文文档:

encodeRedirectURL

public String encodeRedirectURL(String url)
The default behavior of this method is to return encodeRedirectURL(String url) on the wrapped response object.

Specified by:
encodeRedirectURL in interface HttpServletResponse
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.
See Also:
HttpServletResponse.sendRedirect(java.lang.String), HttpServletResponse.encodeUrl(java.lang.String)

public String encodeUrl(String url)
此方法的默认行为是对包装的响应对象调用 encodeUrl(String url)。
英文文档:

encodeUrl

public String encodeUrl(String url)
The default behavior of this method is to call encodeUrl(String url) on the wrapped response object.

Specified by:
encodeUrl in interface HttpServletResponse
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

public String encodeRedirectUrl(String url)
此方法的默认行为是返回对包装的响应对象调用 encodeRedirectUrl(String url) 的结果。
英文文档:

encodeRedirectUrl

public String encodeRedirectUrl(String url)
The default behavior of this method is to return encodeRedirectUrl(String url) on the wrapped response object.

Specified by:
encodeRedirectUrl in interface HttpServletResponse
Parameters:
url - the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

public void sendError(int sc, String msg) throws java.io.IOException
此方法的默认行为是对包装的响应对象调用 sendError(int sc, String msg)。
英文文档:

sendError

public void sendError(int sc,
                      String msg)
               throws IOException
The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.

Specified by:
sendError in interface HttpServletResponse
Parameters:
sc - the error status code
msg - the descriptive message
Throws:
IOException - If an input or output exception occurs

public void sendError(int sc) throws java.io.IOException
此方法的默认行为是对包装的响应对象调用 sendError(int sc)。
英文文档:

sendError

public void sendError(int sc)
               throws IOException
The default behavior of this method is to call sendError(int sc) on the wrapped response object.

Specified by:
sendError in interface HttpServletResponse
Parameters:
sc - the error status code
Throws:
IOException - If an input or output exception occurs

public void sendRedirect(String location) throws java.io.IOException
此方法的默认行为是返回对包装的响应对象调用 sendRedirect(String location) 的结果。
英文文档:

sendRedirect

public void sendRedirect(String location)
                  throws IOException
The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.

Specified by:
sendRedirect in interface HttpServletResponse
Parameters:
location - the redirect location URL
Throws:
IOException - If an input or output exception occurs

public void setDateHeader(String name, long date)
此方法的默认行为是对包装的响应对象调用 setDateHeader(String name, long date)。
英文文档:

setDateHeader

public void setDateHeader(String name,
                          long date)
The default behavior of this method is to call setDateHeader(String name, long date) on the wrapped response object.

Specified by:
setDateHeader in interface HttpServletResponse
Parameters:
name - the name of the header to set
date - the assigned date value
See Also:
HttpServletResponse.containsHeader(java.lang.String), HttpServletResponse.addDateHeader(java.lang.String, long)

public void addDateHeader(String name, long date)
此方法的默认行为是对包装的响应对象调用 addDateHeader(String name, long date)。
英文文档:

addDateHeader

public void addDateHeader(String name,
                          long date)
The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object.

Specified by:
addDateHeader in interface HttpServletResponse
Parameters:
name - the name of the header to set
date - the additional date value
See Also:
HttpServletResponse.setDateHeader(java.lang.String, long)

public void setHeader(String name, String value)
此方法的默认行为是返回对包装的响应对象调用 setHeader(String name, String value) 的结果。
英文文档:

setHeader

public void setHeader(String name,
                      String value)
The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.

Specified by:
setHeader in interface HttpServletResponse
Parameters:
name - the name of the header
value - the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
See Also:
HttpServletResponse.containsHeader(java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String)

public void addHeader(String name, String value)
此方法的默认行为是返回对包装的响应对象调用 addHeader(String name, String value) 的结果。
英文文档:

addHeader

public void addHeader(String name,
                      String value)
The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.

Specified by:
addHeader in interface HttpServletResponse
Parameters:
name - the name of the header
value - the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
See Also:
HttpServletResponse.setHeader(java.lang.String, java.lang.String)

public void setIntHeader(String name, int value)
此方法的默认行为是对包装的响应对象调用 setIntHeader(String name, int value)。
英文文档:

setIntHeader

public void setIntHeader(String name,
                         int value)
The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.

Specified by:
setIntHeader in interface HttpServletResponse
Parameters:
name - the name of the header
value - the assigned integer value
See Also:
HttpServletResponse.containsHeader(java.lang.String), HttpServletResponse.addIntHeader(java.lang.String, int)

public void addIntHeader(String name, int value)
此方法的默认行为是对包装的响应对象调用 addIntHeader(String name, int value)。
英文文档:

addIntHeader

public void addIntHeader(String name,
                         int value)
The default behavior of this method is to call addIntHeader(String name, int value) on the wrapped response object.

Specified by:
addIntHeader in interface HttpServletResponse
Parameters:
name - the name of the header
value - the assigned integer value
See Also:
HttpServletResponse.setIntHeader(java.lang.String, int)

public void setStatus(int sc)
此方法的默认行为是对包装的响应对象调用 setStatus(int sc)。
英文文档:

setStatus

public void setStatus(int sc)
The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

Specified by:
setStatus in interface HttpServletResponse
Parameters:
sc - the status code
See Also:
HttpServletResponse.sendError(int, java.lang.String)

public void setStatus(int sc, String sm)
此方法的默认行为是对包装的响应对象调用 setStatus(int sc, String sm)。
英文文档:

setStatus

public void setStatus(int sc,
                      String sm)
The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object.

Specified by:
setStatus in interface HttpServletResponse
Parameters:
sc - the status code
sm - the status message


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!