|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.servlet Class ServletRequestWrapper
java.lang.Object javax.servlet.ServletRequestWrapper
- All Implemented Interfaces:
- ServletRequest
- Direct Known Subclasses:
- HttpServletRequestWrapper
public class ServletRequestWrapper
- extends Object
- implements ServletRequest
提供 ServletRequest 接口的便捷实现,希望将请求适配到 Servlet 的开发人员可以子类化该接口。此类实现 Wrapper 或 Decorator 模式。默认情况下,方法通过包装的请求对象调用。
since |
| |
See also | javax.servlet.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.
- Since:
- v 2.3
- See Also:
ServletRequest
Constructor Summary | |
---|---|
ServletRequestWrapper(ServletRequest request)
Creates a ServletRequest adaptor wrapping the given request object. |
Method Summary | |
---|---|
Object |
getAttribute(String name)
The default behavior of this method is to call getAttribute(String name) on the wrapped request object. |
Enumeration |
getAttributeNames()
The default behavior of this method is to return getAttributeNames() on the wrapped request object. |
String |
getCharacterEncoding()
The default behavior of this method is to return getCharacterEncoding() on the wrapped request object. |
int |
getContentLength()
The default behavior of this method is to return getContentLength() on the wrapped request object. |
String |
getContentType()
The default behavior of this method is to return getContentType() on the wrapped request object. |
ServletInputStream |
getInputStream()
The default behavior of this method is to return getInputStream() on the wrapped request object. |
String |
getLocalAddr()
The default behavior of this method is to return getLocalAddr() on the wrapped request object. |
Locale |
getLocale()
The default behavior of this method is to return getLocale() on the wrapped request object. |
Enumeration |
getLocales()
The default behavior of this method is to return getLocales() on the wrapped request object. |
String |
getLocalName()
The default behavior of this method is to return getLocalName() on the wrapped request object. |
int |
getLocalPort()
The default behavior of this method is to return getLocalPort() on the wrapped request object. |
String |
getParameter(String name)
The default behavior of this method is to return getParameter(String name) on the wrapped request object. |
Map |
getParameterMap()
The default behavior of this method is to return getParameterMap() on the wrapped request object. |
Enumeration |
getParameterNames()
The default behavior of this method is to return getParameterNames() on the wrapped request object. |
String[] |
getParameterValues(String name)
The default behavior of this method is to return getParameterValues(String name) on the wrapped request object. |
String |
getProtocol()
The default behavior of this method is to return getProtocol() on the wrapped request object. |
BufferedReader |
getReader()
The default behavior of this method is to return getReader() on the wrapped request object. |
String |
getRealPath(String path)
The default behavior of this method is to return getRealPath(String path) on the wrapped request object. |
String |
getRemoteAddr()
The default behavior of this method is to return getRemoteAddr() on the wrapped request object. |
String |
getRemoteHost()
The default behavior of this method is to return getRemoteHost() on the wrapped request object. |
int |
getRemotePort()
The default behavior of this method is to return getRemotePort() on the wrapped request object. |
ServletRequest |
getRequest()
Return the wrapped request object. |
RequestDispatcher |
getRequestDispatcher(String path)
The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object. |
String |
getScheme()
The default behavior of this method is to return getScheme() on the wrapped request object. |
String |
getServerName()
The default behavior of this method is to return getServerName() on the wrapped request object. |
int |
getServerPort()
The default behavior of this method is to return getServerPort() on the wrapped request object. |
boolean |
isSecure()
The default behavior of this method is to return isSecure() on the wrapped request object. |
void |
removeAttribute(String name)
The default behavior of this method is to call removeAttribute(String name) on the wrapped request object. |
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. |
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 |
---|
public
ServletRequestWrapper(ServletRequest request)
创建包装给定请求对象的 ServletRequest 适配器。
Throws | IllegalArgumentException: 如果 request 为 null |
ServletRequestWrapper
public ServletRequestWrapper(ServletRequest request)
- Creates a ServletRequest adaptor wrapping the given request object.
- Throws:
IllegalArgumentException
- if the request is null
Method Detail |
---|
public ServletRequest
getRequest()
返回包装的请求对象。
英文文档:
getRequest
public ServletRequest getRequest()
- Return the wrapped request object.
public void
setRequest(ServletRequest request)
设置将被包装的请求对象。
Throws | IllegalArgumentException: 如果 request 为 null。 |
setRequest
public void setRequest(ServletRequest request)
- Sets the request object being wrapped.
- Throws:
IllegalArgumentException
- if the request is null.
public Object
getAttribute(String name)
此方法的默认行为是对包装的请求对象调用 getAttribute(String name)。
英文文档:
getAttribute
public Object getAttribute(String name)
- The default behavior of this method is to call getAttribute(String name)
on the wrapped request object.
- Specified by:
getAttribute
in interfaceServletRequest
- Parameters:
name
- aString
specifying the name of the attribute- Returns:
- an
Object
containing the value of the attribute, ornull
if the attribute does not exist
public java.util.Enumeration<E>
getAttributeNames()
此方法的默认行为是返回对包装的请求对象调用 getAttributeNames() 的结果。
英文文档:
getAttributeNames
public Enumeration getAttributeNames()
- The default behavior of this method is to return getAttributeNames()
on the wrapped request object.
- Specified by:
getAttributeNames
in interfaceServletRequest
- Returns:
- an
Enumeration
of strings containing the names of the request's attributes
public String
getCharacterEncoding()
此方法的默认行为是返回对包装的请求对象调用 getCharacterEncoding() 的结果。
英文文档:
getCharacterEncoding
public String getCharacterEncoding()
- The default behavior of this method is to return getCharacterEncoding()
on the wrapped request object.
- Specified by:
getCharacterEncoding
in interfaceServletRequest
- Returns:
- a
String
containing the name of the character encoding, ornull
if the request does not specify a character encoding
public void
setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException
此方法的默认行为是设置包装的请求对象上的字符编码。
英文文档:
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 interfaceServletRequest
- Parameters:
enc
-String
containing the name of the character encoding.- Throws:
UnsupportedEncodingException
- if this ServletRequest is still in a state where a character encoding may be set, but the specified encoding is invalid
public int
getContentLength()
此方法的默认行为是返回对包装的请求对象调用 getContentLength() 的结果。
英文文档:
getContentLength
public int getContentLength()
- The default behavior of this method is to return getContentLength()
on the wrapped request object.
- Specified by:
getContentLength
in interfaceServletRequest
- Returns:
- an integer containing the length of the request body or -1 if the length is not known
public String
getContentType()
此方法的默认行为是返回对包装的请求对象调用 getContentType() 的结果。
英文文档:
getContentType
public String getContentType()
- The default behavior of this method is to return getContentType()
on the wrapped request object.
- Specified by:
getContentType
in interfaceServletRequest
- Returns:
- a
String
containing the name of the MIME type of the request, or null if the type is not known
public ServletInputStream
getInputStream() throws java.io.IOException
此方法的默认行为是返回对包装的请求对象调用 getInputStream() 的结果。
英文文档:
getInputStream
public ServletInputStream getInputStream() throws IOException
- The default behavior of this method is to return getInputStream()
on the wrapped request object.
- Specified by:
getInputStream
in interfaceServletRequest
- Returns:
- a
ServletInputStream
object containing the body of the request - Throws:
IOException
- if an input or output exception occurred
public String
getParameter(String name)
此方法的默认行为是返回对包装的请求对象调用 getParameter(String name) 的结果。
英文文档:
getParameter
public String getParameter(String name)
- The default behavior of this method is to return getParameter(String name)
on the wrapped request object.
- Specified by:
getParameter
in interfaceServletRequest
- Parameters:
name
- aString
specifying the name of the parameter- Returns:
- a
String
representing the single value of the parameter - See Also:
ServletRequest.getParameterValues(java.lang.String)
public java.util.Map<K, V>
getParameterMap()
此方法的默认行为是返回对包装的请求对象调用 getParameterMap() 的结果。
英文文档:
getParameterMap
public Map getParameterMap()
- The default behavior of this method is to return getParameterMap()
on the wrapped request object.
- Specified by:
getParameterMap
in 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.
public java.util.Enumeration<E>
getParameterNames()
此方法的默认行为是返回对包装的请求对象调用 getParameterNames() 的结果。
英文文档:
getParameterNames
public Enumeration getParameterNames()
- The default behavior of this method is to return getParameterNames()
on the wrapped request object.
- Specified by:
getParameterNames
in interfaceServletRequest
- Returns:
- an
Enumeration
ofString
objects, eachString
containing the name of a request parameter; or an emptyEnumeration
if the request has no parameters
public String[]
getParameterValues(String name)
此方法的默认行为是返回对包装的请求对象调用 getParameterValues(String name) 的结果。
英文文档:
getParameterValues
public String[] getParameterValues(String name)
- The default behavior of this method is to return getParameterValues(String name)
on the wrapped request object.
- Specified by:
getParameterValues
in interfaceServletRequest
- Parameters:
name
- aString
containing the name of the parameter whose value is requested- Returns:
- an array of
String
objects containing the parameter's values - See Also:
ServletRequest.getParameter(java.lang.String)
public String
getProtocol()
此方法的默认行为是返回对包装的请求对象调用 getProtocol() 的结果。
英文文档:
getProtocol
public String getProtocol()
- The default behavior of this method is to return getProtocol()
on the wrapped request object.
- Specified by:
getProtocol
in interfaceServletRequest
- Returns:
- a
String
containing the protocol name and version number
public String
getScheme()
此方法的默认行为是返回对包装的请求对象调用 getScheme() 的结果。
英文文档:
getScheme
public String getScheme()
- The default behavior of this method is to return getScheme()
on the wrapped request object.
- Specified by:
getScheme
in interfaceServletRequest
- Returns:
- a
String
containing the name of the scheme used to make this request
public String
getServerName()
此方法的默认行为是返回对包装的请求对象调用 getServerName() 的结果。
英文文档:
getServerName
public String getServerName()
- The default behavior of this method is to return getServerName()
on the wrapped request object.
- Specified by:
getServerName
in interfaceServletRequest
- Returns:
- a
String
containing the name of the server
public int
getServerPort()
此方法的默认行为是返回对包装的请求对象调用 getServerPort() 的结果。
英文文档:
getServerPort
public int getServerPort()
- The default behavior of this method is to return getServerPort()
on the wrapped request object.
- Specified by:
getServerPort
in interfaceServletRequest
- Returns:
- an integer specifying the port number
public java.io.BufferedReader
getReader() throws java.io.IOException
此方法的默认行为是返回对包装的请求对象调用 getReader() 的结果。
英文文档:
getReader
public BufferedReader getReader() throws IOException
- The default behavior of this method is to return getReader()
on the wrapped request object.
- Specified by:
getReader
in interfaceServletRequest
- Returns:
- a
BufferedReader
containing the body of the request - Throws:
IOException
- if an input or output exception occurred- See Also:
ServletRequest.getInputStream()
public String
getRemoteAddr()
此方法的默认行为是返回对包装的请求对象调用 getRemoteAddr() 的结果。
英文文档:
getRemoteAddr
public String getRemoteAddr()
- The default behavior of this method is to return getRemoteAddr()
on the wrapped request object.
- Specified by:
getRemoteAddr
in interfaceServletRequest
- Returns:
- a
String
containing the IP address of the client that sent the request
public String
getRemoteHost()
此方法的默认行为是返回对包装的请求对象调用 getRemoteHost() 的结果。
英文文档:
getRemoteHost
public String getRemoteHost()
- The default behavior of this method is to return getRemoteHost()
on the wrapped request object.
- Specified by:
getRemoteHost
in interfaceServletRequest
- Returns:
- a
String
containing the fully qualified name of the client
public void
setAttribute(String name, Object o)
此方法的默认行为是返回对包装的请求对象调用 setAttribute(String name, Object o) 的结果。
英文文档:
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.
- Specified by:
setAttribute
in interfaceServletRequest
- Parameters:
name
- aString
specifying the name of the attributeo
- theObject
to be stored
public void
removeAttribute(String name)
此方法的默认行为是对包装的请求对象调用 removeAttribute(String name)。
英文文档:
removeAttribute
public void removeAttribute(String name)
- The default behavior of this method is to call removeAttribute(String name)
on the wrapped request object.
- Specified by:
removeAttribute
in interfaceServletRequest
- Parameters:
name
- aString
specifying the name of the attribute to remove
public java.util.Locale
getLocale()
此方法的默认行为是返回对包装的请求对象调用 getLocale() 的结果。
英文文档:
getLocale
public Locale getLocale()
- The default behavior of this method is to return getLocale()
on the wrapped request object.
- Specified by:
getLocale
in interfaceServletRequest
- Returns:
- the preferred
Locale
for the client
public java.util.Enumeration<E>
getLocales()
此方法的默认行为是返回对包装的请求对象调用 getLocales() 的结果。
英文文档:
getLocales
public Enumeration getLocales()
- The default behavior of this method is to return getLocales()
on the wrapped request object.
- Specified by:
getLocales
in interfaceServletRequest
- Returns:
- an
Enumeration
of preferredLocale
objects for the client
public boolean
isSecure()
此方法的默认行为是返回对包装的请求对象调用 isSecure() 的结果。
英文文档:
isSecure
public boolean isSecure()
- The default behavior of this method is to return isSecure()
on the wrapped request object.
- Specified by:
isSecure
in interfaceServletRequest
- Returns:
- a boolean indicating if the request was made using a secure channel
public RequestDispatcher
getRequestDispatcher(String path)
此方法的默认行为是返回对包装的请求对象调用 getRequestDispatcher(String path) 的结果。
英文文档:
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path)
- The default behavior of this method is to return getRequestDispatcher(String path)
on the wrapped request object.
- Specified by:
getRequestDispatcher
in interfaceServletRequest
- Parameters:
path
- aString
specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.- Returns:
- a
RequestDispatcher
object that acts as a wrapper for the resource at the specified path, ornull
if the servlet container cannot return aRequestDispatcher
- See Also:
RequestDispatcher
,ServletContext.getRequestDispatcher(java.lang.String)
public String
getRealPath(String path)
此方法的默认行为是返回对包装的请求对象调用 getRealPath(String path) 的结果。
英文文档:
getRealPath
public String getRealPath(String path)
- The default behavior of this method is to return getRealPath(String path)
on the wrapped request object.
- Specified by:
getRealPath
in interfaceServletRequest
public int
getRemotePort()
此方法的默认行为是返回对包装的请求对象调用 getRemotePort() 的结果。
since | 2.4 |
getRemotePort
public int getRemotePort()
- The default behavior of this method is to return
getRemotePort() on the wrapped request object.
- Specified by:
getRemotePort
in interfaceServletRequest
- Returns:
- an integer specifying the port number
- Since:
- 2.4
public String
getLocalName()
此方法的默认行为是返回对包装的请求对象调用 getLocalName() 的结果。
since | 2.4 |
getLocalName
public String getLocalName()
- The default behavior of this method is to return
getLocalName() on the wrapped request object.
- Specified by:
getLocalName
in interfaceServletRequest
- Returns:
- a
String
containing the host name of the IP on which the request was received. - Since:
- 2.4
public String
getLocalAddr()
此方法的默认行为是返回对包装的请求对象调用 getLocalAddr() 的结果。
since | 2.4 |
getLocalAddr
public String getLocalAddr()
- The default behavior of this method is to return
getLocalAddr() on the wrapped request object.
- Specified by:
getLocalAddr
in interfaceServletRequest
- Returns:
- a
String
containing the IP address on which the request was received. - Since:
- 2.4
public int
getLocalPort()
此方法的默认行为是返回对包装的请求对象调用 getLocalPort() 的结果。
since | 2.4 |
getLocalPort
public int getLocalPort()
- The default behavior of this method is to return
getLocalPort() on the wrapped request object.
- Specified by:
getLocalPort
in interfaceServletRequest
- Returns:
- an integer specifying the port number
- Since:
- 2.4
|
|||||||||
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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!