当前位置:编程学习 > JSP >>

不是一个跳转的概念

答案:如果看过jsp生成的servlet的话,forward是这么得来的:
JspFactory  factory = JspFactory.getDefaultFactory();
PageContext pageContext = factory.getPageContext(this,request,response,null,false,JspWriter.DEFAULT_BUFFER,true);
pageContext.forward("...");

什么又是PageContext呢?
A PageContext instance provides access to all the namespaces associated with a JSP page, provides access to several page attributes, as well as a layer above the implementation details.
这是api上的解释,我的感觉呢,就是PageContext控制jsp中所有的缺省属性,包括request,response,out,session等等。既然可以把这些属性取出来,也可以把这些属性加进去,如果我加入这些属性再加载一个jsp会怎么样呢?这就是forward的形成。

上一个:Testing objectives for SCJD
下一个:Java常见问题集锦 (1)--来自SUN中国

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,