JspFragement的invoke方法理解

查看java官方文档:http://tomcat.apache.org/tomcat-5.5-doc/jspapi/javax/servlet/jsp/tagext/JspFragment.html :

abstract  void invoke (java.io.Writer out)
          Executes the fragment and directs all output to the given Writer, or the JspWriter returned by the getOut() method of the JspContext associated with the fragment if out is null.

Parameters:
out - The Writer to output the fragment to, or null if output should be sent to JspContext.getOut().

简单的讲,如果invoke的参数out不为空的话,那么可以使用这个out参数得到tag的body的内容。然后使用getJspContext().getOut()将上面通过out得到的内容处理完成之后,输出到页面中。



posted @ 2010-10-11 21:52  qiang.xu  阅读(1280)  评论(0编辑  收藏  举报