`
isiqi
  • 浏览: 16581764 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

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.

分享到:
评论

相关推荐

    javax.servlet.jar下载

    javax.servlet.RequestDispatcher.class javax.servlet.Servlet.class javax.servlet.ServletException.class javax.servlet.ServletRequest.class javax.servlet.ServletResponse.class javax.servlet....

    javax.servlet帮助文档

    javax.servlet是Java Servlet API的核心部分,它为开发Web应用程序提供了标准的接口和类。这个帮助文档是老师提供的,旨在帮助学生理解和使用这个API来构建基于Java的Web服务。以下是对javax.servlet关键知识点的...

    javax.servlet 包说明

    6. **RequestDispatcher**:`javax.servlet.RequestDispatcher`接口用于转发请求和重定向。通过`HttpServletRequest.getRequestDispatcher()`和`ServletContext.getRequestDispatcher()`方法获取实例,用于将请求...

    servlet-api-2.4.jar.zip

    javax.servlet.RequestDispatcher javax.servlet.SingleThreadModel javax.servlet.ServletInputStream javax.servlet.ServletContextEvent javax.servlet.ServletOutputStream javax.servlet.ServletRequestEvent ...

    servlet2.4doc

    forward(ServletRequest, ServletResponse) - Method in interface javax.servlet.RequestDispatcher Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server. ...

    jsp-api.jar和servlet-api.jar

    `javax.servlet.RequestDispatcher`用于转发请求和包含资源,而`javax.servlet.ServletConfig`包含了Servlet的配置信息。 **标签和压缩包子文件的文件名称列表** 标签"jsp-api.jar"表明我们关注的是JSP相关的API。...

    servlet-api 各种版本

    - 提供了RequestDispatcher接口,用于请求转发和包含,增强了页面间通信。 - 引入了ServletConfig接口,为Servlet提供配置信息。 - 支持多线程模型,允许多个请求同时处理。 2. **Servlet 2.3**: - 发布于2000...

    servlet.jar包

    5. javax.servlet.RequestDispatcher:用于转发请求和包含资源,支持请求的定向。 6. javax.servlet.ServletRequest和ServletResponse:分别表示HTTP请求和响应,提供了获取请求数据和设置响应内容的方法。 此外,...

    Servlet API中文文档

    此外,`javax.servlet.RequestDispatcher`接口用于请求转发和包含,这使得在一个Servlet中调用另一个Servlet或者JSP页面成为可能。 总的来说,Servlet API中文文档是Java Web开发者不可或缺的学习资源,它涵盖了从...

    Java-filter过滤器在项目开发中的应用.docx

    import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; ...

    关于servlet的jar包

    这个JAR包包含了Servlet接口和相关的类,如`javax.servlet.Servlet`、`javax.servlet.ServletRequest`、`javax.servlet.ServletResponse`等,它们定义了Servlet开发者需要实现或继承的方法。 在开发过程中,如果...

    Java filter过滤器在项目开发中的应用.doc

    import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; ...

    用户登录过滤相关页面,过滤URL越权访问

    import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; ...

    jsp servlet面试题总结

    1. RequestDispatcher.forward() 方法:仅是容器中控制权的转向,在客户端浏览器地址栏中不会显示出转向后的地址,不会改变 Request 的值。 2. HttpServletResponse.sendRedirect() 方法:完全的跳转,浏览器将会...

    javax.servlet-api:Java Servlet API规范规范原始代码阅读笔记

    `javax.servlet-api`是这个API的官方实现,通常作为开发环境中的依赖库,而不是在生产环境中直接使用,因为实际的Servlet容器如Tomcat、Jetty等已经包含了这些API的实现。 在阅读`javax.servlet-api`的源代码时,...

    servlet中方法执行次序及API简介(init,service,doservice,doget等)

    - **javax.servlet.RequestDispatcher**:负责请求转发和重定向,常用的方法有forward()和include()。 - **javax.servlet.ServletConfig**:在Servlet初始化时,由容器传递给Servlet,包含了Servlet的配置信息。 - *...

    servlet核心技术.ppt

    在`javax.servlet`包中,有关键的接口如`Servlet`、`ServletConfig`、`ServletContext`、`ServletRequest`、`ServletResponse`、`RequestDispatcher`和`SingleThreadModel`。这些接口定义了Servlet与服务器交互的...

    servlet和JSP面试题答案.pdf

    在 Servlet 中,有两种跳转方法:RequestDispatcher.forward() 方法和 HttpServletResponse.sendRedirect() 方法。 RequestDispatcher.forward() 方法仅是容器中控制权的转向,在客户端浏览器地址栏中不会显示出...

    JSP和Servlet工程师培训10

    - **JSP API**:包括`javax.servlet.jsp`和`javax.servlet.jsp.tagext`包,提供了如`PageContext`, `RequestDispatcher`, `JspWriter`等接口和类,用于页面上下文管理、转发和重定向以及输出数据。 - **Servlet API*...

    JavaServlet编程及应用(一).pdf

    RequestDispatcher接口是javax.servlet包中的一个重要部分,它允许Servlet将请求转发到服务器上的其他资源,增强了Web应用程序的路由能力。除此之外,Servlet API还包含Filter接口,用于实现请求和响应的拦截处理,...

Global site tag (gtag.js) - Google Analytics