[url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview
Class
JavaTM 2 Platform
Ent. Ed. v1.4
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
javax.servlet
Class ServletRequestWrapper
javax.servlet.ServletRequestWrapper
All Implemented Interfaces: ServletRequest Direct Known Subclasses: HttpServletRequestWrapper public class ServletRequestWrapper extends Object implements ServletRequest
Provides a convenient implementation of the ServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object. 提供了一种实现ServletRequest接口的便捷方式,开发人员想采用Servlet请求的话, 可以对其子类化。该类实现了包装或装饰模式。方法默认调用经过包装的请求对象。
Since: v 2.3 See Also: ServletRequest
Constructor Summary
ServletRequestWrapper(ServletRequest request)
Creates a ServletRequest adaptor wrapping the given request object. 创建一个ServletRequest适配器,包装指定的请求对象。
Method Summary
getAttribute(String name)
The default behavior of this method is to call getAttribute(String name) on the wrapped request object. 该方法的默认行为是调用经过包装的请求对象的getAttribute(String name)。
The default behavior of this method is to return getAttributeNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getAttributeNames()。
The default behavior of this method is to return getCharacterEncoding() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getCharacterEncoding()。
int
The default behavior of this method is to return getContentLength() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentLength()。
The default behavior of this method is to return getContentType() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentType()。
The default behavior of this method is to return getInputStream() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getInputStream()。
The default behavior of this method is to return getLocalAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalAddr()。
The default behavior of this method is to return getLocale() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocale()。
The default behavior of this method is to return getLocales() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocales()。
The default behavior of this method is to return getLocalName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalName()。
int
The default behavior of this method is to return getLocalPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalPort()。
getParameter(String name)
The default behavior of this method is to return getParameter(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameter(String name)。
The default behavior of this method is to return getParameterMap() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterMap()。
The default behavior of this method is to return getParameterNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterNames()。
String[]
getParameterValues(String name)
The default behavior of this method is to return getParameterValues(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterValues(String name)。
The default behavior of this method is to return getProtocol() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getProtocol()。
The default behavior of this method is to return getReader() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getReader()。
getRealPath(String path)
The default behavior of this method is to return getRealPath(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRealPath(String path)。
The default behavior of this method is to return getRemoteAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteAddr()。
The default behavior of this method is to return getRemoteHost() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteHost()。
int
The default behavior of this method is to return getRemotePort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemotePort()。
Return the wrapped request object. 返回包装的请求对象。
getRequestDispatcher(String path)
The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRequestDispatcher(String path)。
The default behavior of this method is to return getScheme() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getScheme()。
The default behavior of this method is to return getServerName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerName()。
int
The default behavior of this method is to return getServerPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerPort()。
boolean
isSecure()
The default behavior of this method is to return isSecure() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的isSecure()。
void
removeAttribute(String name)
The default behavior of this method is to call removeAttribute(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的removeAttribute(String name)。
void
setAttribute(String name, Object o)
The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的setAttribute(String name, Object o)。
void
setCharacterEncoding(String enc)
The default behavior of this method is to set the character encoding on the wrapped request object. 该方法的默认行为是设置经过包装的请求对象的字符编码。
void
setRequest(ServletRequest request)
Sets the request object being wrapped. 设置被包装的请求对象。
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ServletRequestWrapper
public ServletRequestWrapper(ServletRequest request)
Creates a ServletRequest adaptor wrapping the given request object. 创建一个ServletRequest适配器,包装指定的请求对象。
Throws: IllegalArgumentException - if the request is null 如果请求为null时抛出
Method Detail
getRequest
public ServletRequest getRequest()
Return the wrapped request object. 返回包装的请求对象。
setRequest
public void setRequest(ServletRequest request)
Sets the request object being wrapped. 设置被包装的请求对象。
Throws: IllegalArgumentException - if the request is null. 如果请求为null时抛出。
getAttribute
public Object getAttribute(String name)
The default behavior of this method is to call getAttribute(String name) on the wrapped request object. 该方法的默认行为是调用经过包装的请求对象的getAttribute(String name)。
Specified by: getAttribute in interface ServletRequestParameters: name - a String specifying the name of the attribute String,表示属性名称 Returns: an Object containing the value of the attribute, or null if the attribute does not exist Object,表示属性值,如果该属性不存在,返回null
getAttributeNames
public Enumeration getAttributeNames()
The default behavior of this method is to return getAttributeNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getAttributeNames()。
Specified by: getAttributeNames in interface ServletRequestReturns: an Enumeration of strings containing the names of the request's attributes 字符串的枚举,表示请求属性的名称
getCharacterEncoding
public String getCharacterEncoding()
The default behavior of this method is to return getCharacterEncoding() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getCharacterEncoding()。
Specified by: getCharacterEncoding in interface ServletRequestReturns: a String containing the name of the chararacter encoding, or null if the request does not specify a character encoding String,表示字符编码名称,如果请求未指定字符编码,返回null
setCharacterEncoding
public void setCharacterEncoding(String enc)
throws UnsupportedEncodingException
The default behavior of this method is to set the character encoding on the wrapped request object. 该方法的默认行为是设置经过包装的请求对象的字符编码。
Specified by: setCharacterEncoding in interface ServletRequestParameters: enc - a String containing the name of the chararacter encoding. String,表示字符编码名称。 Throws: UnsupportedEncodingException - if this is not a valid encoding 如果这是一个无效的编码时抛出
getContentLength
public int getContentLength()
The default behavior of this method is to return getContentLength() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentLength()。
Specified by: getContentLength in interface ServletRequestReturns: an integer containing the length of the request body or -1 if the length is not known 整数,表示请求体的长度,长度未知则为-1
getContentType
public String getContentType()
The default behavior of this method is to return getContentType() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentType()。
Specified by: getContentType in interface ServletRequestReturns: a String containing the name of the MIME type of the request, or null if the type is not known String,表示请求的MIME类型名称,如果类型未知,返回null
getInputStream
public ServletInputStream getInputStream()
throws IOException
The default behavior of this method is to return getInputStream() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getInputStream()。
Specified by: getInputStream in interface ServletRequestReturns: a ServletInputStream object containing the body of the request ServletInputStream对象,表示请求体 Throws: IOException - if an input or output exception occurred 如果发生输入输出异常时抛出
getParameter
public String getParameter(String name)
The default behavior of this method is to return getParameter(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameter(String name)。
Specified by: getParameter in interface ServletRequestParameters: name - a String specifying the name of the parameter String,表示参数名称 Returns: a String representing the single value of the parameter String,表示参数的唯一值 See Also: ServletRequest.getParameterValues(java.lang.String)
getParameterMap
public Map getParameterMap()
The default behavior of this method is to return getParameterMap() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterMap()。
Specified by: getParameterMap in interface ServletRequestReturns: an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array. 一个不变的java.util.Map,key为参数名称,map值为参数值。 在参数map中key为String类型,值为String数组类型。
getParameterNames
public Enumeration getParameterNames()
The default behavior of this method is to return getParameterNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterNames()。
Specified by: getParameterNames in interface ServletRequestReturns: an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters String对象的枚举,每一个String为请求参数的名称;如果请求不含参数,返回空枚举
getParameterValues
public String[] getParameterValues(String name)
The default behavior of this method is to return getParameterValues(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterValues(String name)。
Specified by: getParameterValues in interface ServletRequestParameters: name - a String containing the name of the parameter whose value is requested String,请求值的参数名称 Returns: an array of String objects containing the parameter's values String对象数组,表示参数的值 See Also: ServletRequest.getParameter(java.lang.String)
getProtocol
public String getProtocol()
The default behavior of this method is to return getProtocol() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getProtocol()。
Specified by: getProtocol in interface ServletRequestReturns: a String containing the protocol name and version number String,表示协议名称和版本号
getScheme
public String getScheme()
The default behavior of this method is to return getScheme() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getScheme()。
Specified by: getScheme in interface ServletRequestReturns: a String containing the name of the scheme used to make this request String,表示用来生成请求的模式名称
getServerName
public String getServerName()
The default behavior of this method is to return getServerName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerName()。
Specified by: getServerName in interface ServletRequestReturns: a String containing the name of the server String,表示服务器名称
getServerPort
public int getServerPort()
The default behavior of this method is to return getServerPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerPort()。
Specified by: getServerPort in interface ServletRequestReturns: an integer specifying the port number 整数,表示端口号
getReader
public BufferedReader getReader()
throws IOException
The default behavior of this method is to return getReader() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getReader()。
Specified by: getReader in interface ServletRequestReturns: a BufferedReader containing the body of the request BufferedReader,表示请求体 Throws: IOException - if an input or output exception occurred 如果发生输入输出异常时抛出 See Also: ServletRequest.getInputStream()
getRemoteAddr
public String getRemoteAddr()
The default behavior of this method is to return getRemoteAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteAddr()。
Specified by: getRemoteAddr in interface ServletRequestReturns: a String containing the IP address of the client that sent the request String,表示发送请求的客户端IP地址
getRemoteHost
public String getRemoteHost()
The default behavior of this method is to return getRemoteHost() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteHost()。
Specified by: getRemoteHost in interface ServletRequestReturns: a String containing the fully qualified name of the client String,表示客户端全名称
setAttribute
public void setAttribute(String name,
Object o)
The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的setAttribute(String name, Object o)。
Specified by: setAttribute in interface ServletRequestParameters: name - a String specifying the name of the attribute String,表示属性名称 o - the Object to be stored 要保存的Object
removeAttribute
public void removeAttribute(String name)
The default behavior of this method is to call removeAttribute(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的removeAttribute(String name)。
Specified by: removeAttribute in interface ServletRequestParameters: name - a String specifying the name of the attribute to remove String,指定要删除的属性名称
getLocale
public Locale getLocale()
The default behavior of this method is to return getLocale() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocale()。
Specified by: getLocale in interface ServletRequestReturns: the preferred Locale for the client 客户端采用的Locale
getLocales
public Enumeration getLocales()
The default behavior of this method is to return getLocales() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocales()。
Specified by: getLocales in interface ServletRequestReturns: an Enumeration of preferred Locale objects for the client 客户端采用的Locale对象枚举
isSecure
public boolean isSecure()
The default behavior of this method is to return isSecure() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的isSecure()。
Specified by: isSecure in interface ServletRequestReturns: a boolean indicating if the request was made using a secure channel 布尔值,表示请求是否使用安全通道发出
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path)
The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRequestDispatcher(String path)。
Specified by: getRequestDispatcher in interface ServletRequestParameters: path - a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet. String,表示资源路径名。如果是相对的,必须相对于当前servlet。 Returns: a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the servlet container cannot return a RequestDispatcher RequestDispatcher对象,作为指定路径的资源包装器,如果servlet容器不能返回RequestDispatcher, 那么返回null See Also: RequestDispatcher, ServletContext.getRequestDispatcher(java.lang.String)
getRealPath
public String getRealPath(String path)
The default behavior of this method is to return getRealPath(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRealPath(String path)。
Specified by: getRealPath in interface ServletRequest
getRemotePort
public int getRemotePort()
The default behavior of this method is to return getRemotePort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemotePort()。
Specified by: getRemotePort in interface ServletRequestSince: 2.4
getLocalName
public String getLocalName()
The default behavior of this method is to return getLocalName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalName()。
Specified by: getLocalName in interface ServletRequestReturns: a String containing the host name of the IP on which the request was received. String,表示收到请求的IP主机名。 Since: 2.4
getLocalAddr
public String getLocalAddr()
The default behavior of this method is to return getLocalAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalAddr()。
Specified by: getLocalAddr in interface ServletRequestReturns: a String containing the IP address on which the request was received. String,表示收到请求的IP地址。 Since: 2.4
getLocalPort
public int getLocalPort()
The default behavior of this method is to return getLocalPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalPort()。
Specified by: getLocalPort in interface ServletRequestReturns: an integer specifying the port number 整数,表示端口号 Since: 2.4 [/url]
[url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview
Class
JavaTM 2 Platform
Ent. Ed. v1.4
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright 2003 Sun Microsystems, Inc. All rights reserved.