在一个可重用的代码中,我使用< jsp:include page =“reuse.html”/>在第二个,我使用
reusable
As the candle burns,so do I
运行这两个JSP文件后,您看到相同的输出,并认为指令和标记之间有任何差异。但是,如果你看看生成的servlet的两个JSP文件,你会看到差异。这是你会看到当你使用指令:
out.write("\r\n");
out.write("
\r\n");out.write("
reusable\r\n");out.write(" \r\n");
out.write(" \r\n");
out.write("
\r\n");out.write("
\r\n");
out.write("
As the candle burns,so do I
\r\n");out.write(" \r\n");
out.write("\r\n");
这是您将在第二个JSP文件中使用的标记中看到的:
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "reusable.html", out, false);
所以现在你知道include指令在翻译时插入reuse.html的源,但action标签在运行时插入reuse.html的响应。
如果你想到它,每个action标签(jsp:include文件)都有额外的性能。这意味着您可以保证您将始终拥有最新的内容,但它会提高性能成本。