SSI 与 JSP 的区别?
使用SSI include & 有什么区别? JSP包括什么?
例如
<!--#include virtual="page.jsp" -->
和
<%@ include file="page.jsp" %>
What's the difference in using SSI include & JSP include?
e.g.
<!--#include virtual="page.jsp" -->
and
<%@ include file="page.jsp" %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SSI 由网络服务器引擎执行,并且也可以在非 JSP 文件中工作(例如纯 HTML 文件)。它根据每个请求执行。 JSP include 指令由容器的 JSP servlet 执行,并且仅适用于 JSP 文件。它在 JSP 编译时仅执行一次,结果内联到生成的 JSP 类文件中,该文件可多次重用。如果您使用
而不是<%@include%>
,那么它将在每个请求上执行,从而允许更动态的包含。例如,您可以使用
。如果您已经在使用 JSP,我建议改用 JSP include 工具,因为它允许更多优化和动态。
SSI is executed by webserver engine and works in non-JSP files as well (e.g plain HTML files). It's executed on every request. JSP include directive is executed by container's JSP servlet and works in JSP files only. It's executed only once during JSP compile time and the result is inlined in the generated JSP class file which is reused multiple times. If you were using
<jsp:include>
instead of<%@include%>
, then it would be executed on every request which allows for more dynamic includes. You can use for example<jsp:include page="${page}" />
.If you're already using JSP, I'd suggest to utilize the JSP include facilities instead as it allows for more optimisation and dynamics.