|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.servlet.http Class HttpServletResponseWrapper
java.lang.Objectjavax.servlet.ServletResponseWrapper
javax.servlet.http.HttpServletResponseWrapper
- All Implemented Interfaces:
- HttpServletResponse, ServletResponse
public class HttpServletResponseWrapper
- extends ServletResponseWrapper
- implements HttpServletResponse
Extends:
ServletResponseWrapper
Implements:
HttpServletResponse
提供 HttpServletResponse 接口的便捷实现,希望根据 Servlet 适配响应的开发人员可以子类化该接口。此类实现 Wrapper 或 Decorator 模式。默认情况下,方法通过包装的响应对象调用。
| since |
| |
| See also | javax.servlet.http.HttpServletResponse |
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 |
|---|
| Constructor Summary | |
|---|---|
HttpServletResponseWrapper(HttpServletResponse response)
Constructs a response adaptor wrapping the given response. |
|
| Method Summary | |
|---|---|
void |
addCookie(Cookie cookie)
The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object. |
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. |
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. |
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. |
boolean |
containsHeader(String name)
The default behavior of this method is to call containsHeader(String name) on the wrapped response object. |
String |
encodeRedirectUrl(String url)
The default behavior of this method is to return encodeRedirectUrl(String url) on the wrapped response object. |
String |
encodeRedirectURL(String url)
The default behavior of this method is to return encodeRedirectURL(String url) on the wrapped response object. |
String |
encodeUrl(String url)
The default behavior of this method is to call encodeUrl(String url) on the wrapped response object. |
String |
encodeURL(String url)
The default behavior of this method is to call encodeURL(String url) on the wrapped response object. |
void |
sendError(int sc)
The default behavior of this method is to call sendError(int sc) on the wrapped response object. |
void |
sendError(int sc,
String msg)
The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object. |
void |
sendRedirect(String location)
The default behavior of this method is to return sendRedirect(String location) on the wrapped response object. |
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. |
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. |
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. |
void |
setStatus(int sc)
The default behavior of this method is to call setStatus(int sc) on the wrapped response object. |
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. |
| Methods inherited from class javax.servlet.ServletResponseWrapper |
|---|
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getResponse, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale, setResponse |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.ServletResponse |
|---|
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentType, setLocale |
| Constructor Detail |
|---|
public
HttpServletResponseWrapper(HttpServletResponse response)
构造包装给定响应的响应适配器。
| Throws | IllegalArgumentException: 如果 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:
addCookiein interfaceHttpServletResponse
- 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:
containsHeaderin interfaceHttpServletResponse
- Parameters:
name- the header name- Returns:
trueif the named response header has already been set;falseotherwise
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:
encodeURLin interfaceHttpServletResponse
- 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:
encodeRedirectURLin interfaceHttpServletResponse
- 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:
encodeUrlin interfaceHttpServletResponse
- 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:
encodeRedirectUrlin interfaceHttpServletResponse
- 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:
sendErrorin interfaceHttpServletResponse
- Parameters:
sc- the error status codemsg- 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:
sendErrorin interfaceHttpServletResponse
- 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:
sendRedirectin interfaceHttpServletResponse
- 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:
setDateHeaderin interfaceHttpServletResponse
- Parameters:
name- the name of the header to setdate- 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:
addDateHeaderin interfaceHttpServletResponse
- Parameters:
name- the name of the header to setdate- 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:
setHeaderin interfaceHttpServletResponse
- Parameters:
name- the name of the headervalue- 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:
addHeaderin interfaceHttpServletResponse
- Parameters:
name- the name of the headervalue- 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:
setIntHeaderin interfaceHttpServletResponse
- Parameters:
name- the name of the headervalue- 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:
addIntHeaderin interfaceHttpServletResponse
- Parameters:
name- the name of the headervalue- 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:
setStatusin interfaceHttpServletResponse
- 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:
setStatusin interfaceHttpServletResponse
- Parameters:
sc- the status codesm- the status message
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!
