javax.servlet.RequestDispatcher翻译

<!-- ========= START OF TOP NAVBAR ======= --> <!-- -->
JavaTM 2 Platform
Ent. Ed. v1.4
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->

javax.servlet
Interface RequestDispatcher


public interface RequestDispatcher

Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name. 定义了一个对象用来接收客户端的请求,将它们发送给服务器上的任何资源(比如servlet,HTML文件,或者JSP文件)。 servlet容器创建了RequestDispatcher对象,用于包装以特定路径或特定名称定位的服务器资源。

This interface is intended to wrap servlets, but a servlet container can create RequestDispatcher objects to wrap any type of resource. 该接口目的是包装servlet,但是servlet容器创建的RequestDispatcher可以包装任何类型的资源。

Version:
$Version$
Author:
Various
See Also:
ServletContext.getRequestDispatcher(java.lang.String), ServletContext.getNamedDispatcher(java.lang.String), ServletRequest.getRequestDispatcher(java.lang.String)

<!-- ======== NESTED CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><!-- -->

Method Summary
void forward(ServletRequestrequest, ServletResponseresponse)
Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server. 从servlet向服务器上其他资源(servlet,JSP文件或者HTML文件)转发请求。
void include(ServletRequestrequest, ServletResponseresponse)
Includes the content of a resource (servlet, JSP page, HTML file) in the response. 包含响应中的资源(servlet,JSP文件,HTML文件)内容。

<!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><!-- -->

Method Detail
<!-- -->

forward

public void forward(ServletRequestrequest,
                    ServletResponseresponse)
             throws ServletException,
                    IOException
Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server. This method allows one servlet to do preliminary processing of a request and another resource to generate the response. 从servlet向服务器上其他资源(servlet,JSP文件或者HTML文件)转发请求。该方法允许请求和其他资源生成响应之前做一些预处理。

For a RequestDispatcher obtained via getRequestDispatcher(), the ServletRequest object has its path elements and parameters adjusted to match the path of the target resource. 对于通过getRequestDispatcher()获得的RequestDispatcher,ServletRequest对象可以调整路径组成和参数来匹配目标资源的路径。

forward should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException. Uncommitted output in the response buffer is automatically cleared before the forward. forward应当在响应提交给客户端之前调用(响应体输出被刷新前)。如果响应已经被提交,该方法抛出IllegalStateException。响应缓存中未提交的输出在转发之前自动清空。

The request and response parameters must be either the same objects as were passed to the calling servlet's service method or be subclasses of the ServletRequestWrapper or ServletResponseWrapper classes that wrap them. 传递给调用servlet的service方法的请求和响应参数可以是相同的对象,也可以是 对它们进行包装的ServletRequestWrapper或ServletResponseWrapper类的子类。

Parameters:
request - a ServletRequest object that represents the request the client makes of the servlet ServletRequest对象,表示客户端向servlet发出的请求
response - a ServletResponse object that represents the response the servlet returns to the client ServletResponse对象,表示servlet返回给客户端的响应
Throws:
ServletException - if the target resource throws this exception 如果目标资源抛出该异常时抛出
IOException - if the target resource throws this exception 如果目标资源抛出该异常时抛出
IllegalStateException - if the response was already committed 如果响应已经提交则抛出

<!-- -->

include

public void include(ServletRequestrequest,
                    ServletResponseresponse)
             throws ServletException,
                    IOException
Includes the content of a resource (servlet, JSP page, HTML file) in the response. In essence, this method enables programmatic server-side includes. 包含响应中的资源(servlet,JSP文件,HTML文件)内容。本质上,该方法使服务器端包含成为可能。

The ServletResponse object has its path elements and parameters remain unchanged from the caller's. The included servlet cannot change the response status code or set headers; any attempt to make a change is ignored. 来自调用者的ServletResponse对象的路径组成和参数保持不变。包含的servlet 不能改变响应状态代码或设置头;任何变更的企图都会被忽略。

The request and response parameters must be either the same objects as were passed to the calling servlet's service method or be subclasses of the ServletRequestWrapper or ServletResponseWrapper classes that wrap them. 传递给调用servlet的service方法的请求和响应参数可以是相同的对象,也可以是 对它们进行包装的ServletRequestWrapper或ServletResponseWrapper类的子类。

Parameters:
request - a ServletRequest object that contains the client's request ServletRequest对象,表示客户端请求
response - a ServletResponse object that contains the servlet's response ServletResponse对象,表示servlet响应
Throws:
ServletException - if the included resource throws this exception 如果包含的资源抛出该异常时抛出
IOException - if the included resource throws this exception 如果包含的资源抛出该异常时抛出
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== --> <!-- -->
JavaTM 2 Platform
Ent. Ed. v1.4
<!-- ======== END OF BOTTOM NAVBAR ======= -->
Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.

你可能感兴趣的:(html,jsp,servlet,sun)