查看java官方文档:http://tomcat.apache.org/tomcat-5.5-doc/jspapi/javax/servlet/jsp/tagext/JspFragment.html :
abstract void invoke (java.io.Writerout)
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得到的内容处理完成之后,输出到页面中。
本文解析了JspFragment中的invoke方法工作原理。该方法接受一个Writer对象作为参数,如果参数不为空,则使用该对象输出内容;如果参数为空,则默认使用JspContext的getOut方法获取的Writer对象进行输出。
3945

被折叠的 条评论
为什么被折叠?



