getRequestDispatcher
public RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher
object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.
返回一个RequestDispatcher对象,该对象充当位于给定路径的资源的包装器。RequestDispatcher对象可用于将请求转发给资源,或将资源包含在响应中。资源可以是动态的,也可以是静态的。
The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. This method returns null
if the servlet container cannot return a RequestDispatcher
.
指定的路径名可以是相对的,但其不能扩展到当前servlet上下文之外。如果路径以“/”开头,则将被解释为相对于当前上下文根路径。如果servlet容器无法返回RequestDispatcher,则该方法返回null。
The difference between this method and ServletContext.getRequestDispatcher(java.lang.String) is that this method can take a relative path.
此方法与 ServletContext.getRequestDispatcher(java.lang.String) 之间的区别,在于该方法可以采用相对路径。
Parameters:
path
- a String
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, or null
if the servlet container cannot return a RequestDispatcher
See Also:
RequestDispatcher, ServletContext.getRequestDispatcher(java.lang.String)