<!-- -->
| JavaTM 2 Platform Ent. Ed. v1.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> All Classes <noscript></noscript> | |||||||||
| SUMMARY:NESTED|FIELD|CONSTR|METHOD | DETAIL:FIELD|CONSTR|METHOD | |||||||||
javax.servlet
Class 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
<!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- -->
| Constructor Summary | |
ServletRequestWrapper(ServletRequestrequest) Creates a ServletRequest adaptor wrapping the given request object. 创建一个ServletRequest适配器,包装指定的请求对象。 | |
| Method Summary | |
Object | getAttribute(Stringname) The default behavior of this method is to call getAttribute(String name) on the wrapped request object. 该方法的默认行为是调用经过包装的请求对象的getAttribute(String name)。 |
Enumeration | getAttributeNames() The default behavior of this method is to return getAttributeNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getAttributeNames()。 |
String | getCharacterEncoding() The default behavior of this method is to return getCharacterEncoding() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getCharacterEncoding()。 |
int | getContentLength() The default behavior of this method is to return getContentLength() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentLength()。 |
String | getContentType() The default behavior of this method is to return getContentType() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentType()。 |
ServletInputStream | getInputStream() The default behavior of this method is to return getInputStream() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getInputStream()。 |
String | getLocalAddr() The default behavior of this method is to return getLocalAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalAddr()。 |
Locale | getLocale() The default behavior of this method is to return getLocale() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocale()。 |
Enumeration | getLocales() The default behavior of this method is to return getLocales() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocales()。 |
String | getLocalName() The default behavior of this method is to return getLocalName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalName()。 |
int | getLocalPort() The default behavior of this method is to return getLocalPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalPort()。 |
String | getParameter(Stringname) The default behavior of this method is to return getParameter(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameter(String name)。 |
Map | getParameterMap() The default behavior of this method is to return getParameterMap() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterMap()。 |
Enumeration | getParameterNames() The default behavior of this method is to return getParameterNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterNames()。 |
String[] | getParameterValues(Stringname) The default behavior of this method is to return getParameterValues(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterValues(String name)。 |
String | getProtocol() The default behavior of this method is to return getProtocol() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getProtocol()。 |
BufferedReader | getReader() The default behavior of this method is to return getReader() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getReader()。 |
String | getRealPath(Stringpath) The default behavior of this method is to return getRealPath(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRealPath(String path)。 |
String | getRemoteAddr() The default behavior of this method is to return getRemoteAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteAddr()。 |
String | getRemoteHost() The default behavior of this method is to return getRemoteHost() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteHost()。 |
int | getRemotePort() The default behavior of this method is to return getRemotePort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemotePort()。 |
ServletRequest | getRequest() Return the wrapped request object. 返回包装的请求对象。 |
RequestDispatcher | getRequestDispatcher(Stringpath) The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRequestDispatcher(String path)。 |
String | getScheme() The default behavior of this method is to return getScheme() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getScheme()。 |
String | getServerName() The default behavior of this method is to return getServerName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerName()。 |
int | getServerPort() 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(Stringname) The default behavior of this method is to call removeAttribute(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的removeAttribute(String name)。 |
void | setAttribute(Stringname, Objecto) 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(Stringenc) The default behavior of this method is to set the character encoding on the wrapped request object. 该方法的默认行为是设置经过包装的请求对象的字符编码。 |
void | setRequest(ServletRequestrequest) Sets the request object being wrapped. 设置被包装的请求对象。 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
<!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- -->
| Constructor Detail |
ServletRequestWrapper
- Creates a ServletRequest adaptor wrapping the given request object. 创建一个ServletRequest适配器,包装指定的请求对象。 Throws:
-
IllegalArgumentException- if the request is null 如果请求为null时抛出
| Method Detail |
getRequest
- Return the wrapped request object. 返回包装的请求对象。
setRequest
- Sets the request object being wrapped. 设置被包装的请求对象。
-
Throws:
-
IllegalArgumentException- if the request is null. 如果请求为null时抛出。
getAttribute
- The default behavior of this method is to call getAttribute(String name) on the wrapped request object. 该方法的默认行为是调用经过包装的请求对象的getAttribute(String name)。
-
-
Specified by:
-
getAttributein interfaceServletRequest
-
-
-
Parameters:
-
name- aStringspecifying the name of the attribute String,表示属性名称
Returns:
-
an
Objectcontaining the value of the attribute, ornullif the attribute does not exist Object,表示属性值,如果该属性不存在,返回null
-
getAttributeNames
- The default behavior of this method is to return getAttributeNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getAttributeNames()。
-
-
Specified by:
-
getAttributeNamesin interfaceServletRequest
-
-
-
Returns:
-
an
Enumerationof strings containing the names of the request's attributes 字符串的枚举,表示请求属性的名称
-
an
getCharacterEncoding
- The default behavior of this method is to return getCharacterEncoding() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getCharacterEncoding()。
-
-
Specified by:
-
getCharacterEncodingin interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the name of the chararacter encoding, ornullif the request does not specify a character encoding String,表示字符编码名称,如果请求未指定字符编码,返回null
-
a
setCharacterEncoding
- The default behavior of this method is to set the character encoding on the wrapped request object. 该方法的默认行为是设置经过包装的请求对象的字符编码。
-
-
Specified by:
-
setCharacterEncodingin interfaceServletRequest
-
-
-
Parameters:
-
enc- aStringcontaining the name of the chararacter encoding. String,表示字符编码名称。
Throws:
-
UnsupportedEncodingException- if this is not a valid encoding 如果这是一个无效的编码时抛出
-
getContentLength
- The default behavior of this method is to return getContentLength() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentLength()。
-
-
Specified by:
-
getContentLengthin interfaceServletRequest
-
-
-
Returns:
- an integer containing the length of the request body or -1 if the length is not known 整数,表示请求体的长度,长度未知则为-1
getContentType
- The default behavior of this method is to return getContentType() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getContentType()。
-
-
Specified by:
-
getContentTypein interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the name of the MIME type of the request, or null if the type is not known String,表示请求的MIME类型名称,如果类型未知,返回null
-
a
getInputStream
- The default behavior of this method is to return getInputStream() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getInputStream()。
-
-
Specified by:
-
getInputStreamin interfaceServletRequest
-
-
-
Returns:
-
a
ServletInputStreamobject containing the body of the request ServletInputStream对象,表示请求体
Throws:
-
IOException- if an input or output exception occurred 如果发生输入输出异常时抛出
-
a
getParameter
- The default behavior of this method is to return getParameter(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameter(String name)。
-
-
Specified by:
-
getParameterin interfaceServletRequest
-
-
-
Parameters:
-
name- aStringspecifying the name of the parameter String,表示参数名称
Returns:
-
a
Stringrepresenting the single value of the parameter String,表示参数的唯一值
See Also:
-
ServletRequest.getParameterValues(java.lang.String)
-
getParameterMap
- The default behavior of this method is to return getParameterMap() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterMap()。
-
-
Specified by:
-
getParameterMapin interfaceServletRequest
-
-
-
Returns:
- 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
- The default behavior of this method is to return getParameterNames() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterNames()。
-
-
Specified by:
-
getParameterNamesin interfaceServletRequest
-
-
-
Returns:
-
an
EnumerationofStringobjects, eachStringcontaining the name of a request parameter; or an emptyEnumerationif the request has no parameters String对象的枚举,每一个String为请求参数的名称;如果请求不含参数,返回空枚举
-
an
getParameterValues
- The default behavior of this method is to return getParameterValues(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getParameterValues(String name)。
-
-
Specified by:
-
getParameterValuesin interfaceServletRequest
-
-
-
Parameters:
-
name- aStringcontaining the name of the parameter whose value is requested String,请求值的参数名称
Returns:
-
an array of
Stringobjects containing the parameter's values String对象数组,表示参数的值
See Also:
-
ServletRequest.getParameter(java.lang.String)
-
getProtocol
- The default behavior of this method is to return getProtocol() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getProtocol()。
-
-
Specified by:
-
getProtocolin interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the protocol name and version number String,表示协议名称和版本号
-
a
getScheme
- The default behavior of this method is to return getScheme() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getScheme()。
-
-
Specified by:
-
getSchemein interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the name of the scheme used to make this request String,表示用来生成请求的模式名称
-
a
getServerName
- The default behavior of this method is to return getServerName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerName()。
-
-
Specified by:
-
getServerNamein interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the name of the server String,表示服务器名称
-
a
getServerPort
- The default behavior of this method is to return getServerPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getServerPort()。
-
-
Specified by:
-
getServerPortin interfaceServletRequest
-
-
-
Returns:
- an integer specifying the port number 整数,表示端口号
getReader
- The default behavior of this method is to return getReader() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getReader()。
-
-
Specified by:
-
getReaderin interfaceServletRequest
-
-
-
Returns:
-
a
BufferedReadercontaining the body of the request BufferedReader,表示请求体
Throws:
-
IOException- if an input or output exception occurred 如果发生输入输出异常时抛出
See Also:
-
ServletRequest.getInputStream()
-
a
getRemoteAddr
- The default behavior of this method is to return getRemoteAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteAddr()。
-
-
Specified by:
-
getRemoteAddrin interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the IP address of the client that sent the request String,表示发送请求的客户端IP地址
-
a
getRemoteHost
- The default behavior of this method is to return getRemoteHost() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemoteHost()。
-
-
Specified by:
-
getRemoteHostin interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the fully qualified name of the client String,表示客户端全名称
-
a
setAttribute
- 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:
-
setAttributein interfaceServletRequest
-
-
-
Parameters:
-
name- aStringspecifying the name of the attribute String,表示属性名称 -
o- theObjectto be stored 要保存的Object
-
removeAttribute
- The default behavior of this method is to call removeAttribute(String name) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的removeAttribute(String name)。
-
-
Specified by:
-
removeAttributein interfaceServletRequest
-
-
-
Parameters:
-
name- aStringspecifying the name of the attribute to remove String,指定要删除的属性名称
-
getLocale
- The default behavior of this method is to return getLocale() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocale()。
-
-
Specified by:
-
getLocalein interfaceServletRequest
-
-
-
Returns:
-
the preferred
Localefor the client 客户端采用的Locale
-
the preferred
getLocales
- The default behavior of this method is to return getLocales() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocales()。
-
-
Specified by:
-
getLocalesin interfaceServletRequest
-
-
-
Returns:
-
an
Enumerationof preferredLocaleobjects for the client 客户端采用的Locale对象枚举
-
an
isSecure
- The default behavior of this method is to return isSecure() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的isSecure()。
-
-
Specified by:
-
isSecurein interfaceServletRequest
-
-
-
Returns:
- a boolean indicating if the request was made using a secure channel 布尔值,表示请求是否使用安全通道发出
getRequestDispatcher
- The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRequestDispatcher(String path)。
-
-
Specified by:
-
getRequestDispatcherin interfaceServletRequest
-
-
-
Parameters:
-
path- aStringspecifying the pathname to the resource. If it is relative, it must be relative against the current servlet. String,表示资源路径名。如果是相对的,必须相对于当前servlet。
Returns:
-
a
RequestDispatcherobject that acts as a wrapper for the resource at the specified path, ornullif the servlet container cannot return aRequestDispatcher RequestDispatcher对象,作为指定路径的资源包装器,如果servlet容器不能返回RequestDispatcher, 那么返回null
See Also:
-
RequestDispatcher,ServletContext.getRequestDispatcher(java.lang.String)
-
getRealPath
- The default behavior of this method is to return getRealPath(String path) on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRealPath(String path)。
-
-
Specified by:
-
getRealPathin interfaceServletRequest
-
getRemotePort
- The default behavior of this method is to return getRemotePort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getRemotePort()。
-
-
Specified by:
-
getRemotePortin interfaceServletRequest
-
-
-
Since:
- 2.4
getLocalName
- The default behavior of this method is to return getLocalName() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalName()。
-
-
Specified by:
-
getLocalNamein interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the host name of the IP on which the request was received. String,表示收到请求的IP主机名。
Since:
- 2.4
-
a
getLocalAddr
- The default behavior of this method is to return getLocalAddr() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalAddr()。
-
-
Specified by:
-
getLocalAddrin interfaceServletRequest
-
-
-
Returns:
-
a
Stringcontaining the IP address on which the request was received. String,表示收到请求的IP地址。
Since:
- 2.4
-
a
getLocalPort
- The default behavior of this method is to return getLocalPort() on the wrapped request object. 该方法的默认行为是返回经过包装的请求对象的getLocalPort()。
-
-
Specified by:
-
getLocalPortin i
-
本文详细介绍了Servlet中的ServletRequestWrapper类,该类提供了对ServletRequest接口的便捷实现,便于开发者进行自定义扩展。文章涵盖了构造方法、常用方法及其默认行为。
1534

被折叠的 条评论
为什么被折叠?



