The include directive inserts the SOURCE of JSP or HTML files at [b]translation time[/b].
But the <jsp:include/> standard action inserts the RESPONSE of the JSP or HTML files [b]at runtime[/b].
There is an exra perfermance hit with every <jsp:include>. With directive, on the other hand, the hit happens only once --- when the including page is translated.
So if you're pretty sure that once you go to production the including file won't change, the directive might be the way to go. Of course there's still tradeoff that the generated servlet class is a little larger when you use the directive.
Tip:如果including page是经常改动的,则应该使用 <jsp:include/>
But the <jsp:include/> standard action inserts the RESPONSE of the JSP or HTML files [b]at runtime[/b].
There is an exra perfermance hit with every <jsp:include>. With directive, on the other hand, the hit happens only once --- when the including page is translated.
So if you're pretty sure that once you go to production the including file won't change, the directive might be the way to go. Of course there's still tradeoff that the generated servlet class is a little larger when you use the directive.
Tip:如果including page是经常改动的,则应该使用 <jsp:include/>
本文对比了JSP中两种不同的文件包含方式:include指令与<jsp:include/>标准操作的区别。前者在翻译阶段将源文件内容插入到当前JSP文件中,而后者则在运行时动态插入文件响应。文中还探讨了它们在性能上的差异及适用场景。
578

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



