JSP include directive 和JSP include的区别

JSP include directive 和JSP include的区别


拉莫斯之舞
浏览 653回答 2
2回答

一只萌萌小番薯

JSP中的include指令与include动作的区别  在JSP中有两种include操作形式,如下:  <%@ include file=” ”%> (这个等价于<jsp:directive.include page=” ” flush=”true”/>)  <jsp:include page=” ” flush=”true”/>  两种句法的作用在效果上完全相同。前者是指令元素、后者是行为元素。但在性能和维护上却截然不同。  首先,我们知道WEB容器都是将JSP脚本翻译成servlet文件的,下面我们就通过一个示例文件来进一步了解其区别。  首先创建一个被引用的included.html文件:  <b>to beincluded file</b>  在创建一个测试index.jsp文件:  <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>TEST-JSP</title> </head> <body> <%--这里先后用两种方式对文件进行引用--%> <%@include file="included.html" %> <br/> <jsp:include flush="true" page="included.html"$amp;>amp;$lt;/jsp:include> </body> </html>  好了,现在进行部署。
打开App,查看更多内容
随时随地看视频慕课网APP