有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java RequestDispatcher是如何实现的?

我试图弄清楚如何实现RequestDispatcher,所以我检查了tomcat的源代码ApplicationDispatcher类,但是有很多地方我不明白

我在ApplicationDispatcher类中发现,用于将请求和响应转发到指定资源的方法是invoke(ServletRequest,ServletResponse)方法,该部分负责执行转发:

support.fireInstanceEvent(InstanceEvent.BEFORE_DISPATCH_EVENT, servlet, request, response);
// for includes/forwards   
if ((servlet != null) && (filterChain != null)) {
    filterChain.doFilter(request, response);
}
// Servlet Service Method is called by the FilterChain   
support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT, servlet, request, response);

我无法理解这部分代码,这是否意味着RequestDispatcher。forward()和RequestDispatcher。include()方法都在filterchain中执行吗?有谁能告诉我tomcat的ApplicationRequestDispatcher的工作机制吗

提前谢谢


共 (0) 个答案