本文共 684 字,大约阅读时间需要 2 分钟。
1、简介
jsp中include指令的形式为: <%@ include file=" " %> 通常当应用程序中所有的页面的某些部分(例如标题、页脚和导航栏)都相同的时候,就可以考虑用include。<%@ include file=" "%>,jsp的include指令元素读入指定页面的内容。并把这些内容和原来的页面融合到一起。(这个过程是在翻译阶段:也就是jsp被转化成servlet的阶段进行的。)
2、和jsp:include动作指令的不同
include与jsp:include主要有两个方面的不同; 一是执行时间上: <%@ include file=”relativeURI”%> 是在翻译阶段执行 <jsp:include page=”relativeURI” flush=”true” /> 在请求处理阶段执行. 二是引入内容的不同: <%@ include file=”relativeURI”%> 引入静态文本(html,jsp),在JSP页面被转化成servlet之前和它融和到一起. <jsp:include page=”relativeURI” flush=”true” /> 引入执行页面或servlet所生成的应答文本. 另外在两种用法中file和page属性都被解释为一个相对的URI.如果它以斜杠开头,那么它就是一个环境相关的路径.将根据赋给应用程序的URI的前缀进行解释,如果它不是以斜杠开头,那么就是页面相关的路径,就根据引入这个文件的页面所在的路径进行解释。
参考文献:百度百科
转载地址:http://sqdoi.baihongyu.com/