教程集 www.jiaochengji.com
教程集 >  脚本编程  >  java  >  正文 jsp动态include与静态include区别

jsp动态include与静态include区别

发布时间:2016-11-20   编辑:jiaochengji.com
教程集为您提供jsp动态include与静态include区别等资源,欢迎您收藏本站,我们将为您提供最新的jsp动态include与静态include区别资源
在jsp动态include与静态include区别呢,下面我整理了一些网友的经验给各位同学参考一下,希望文章对各位有帮助。

答:动态INCLUDE用jsp:include动作实现

<jsp:include page="included.jsp" flush="true" />它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数


 <%@ include file="included.htm" %> 静态INCLUDE用include伪码实现,定不会检查所含文件的变化,适用于包含静态页面


1. 静态include的结果是把其他jsp引入当前jsp,两者合为一体
    动态include的结构是两者独立,直到输出时才合并( 看看jsp生成的java文件就可以知道了)

2.正是因为这样,动态include的jsp文件独立性很强,是一个单独的jsp文件,需要使用的对象,页面设置,都必须有自己创建,当然,还好它和include它的页面的request范围是一致的.


最后看老q外写的


When you use <jsp:include>, it executed the target in a separate request, and then includes the output in the including JSP. It doesn’t include the source of the included target, it includes the output. The means by which that target output is generated is lost.

To do what you’re trying to do, you need to use <% include %> directives:

<%@ include file="/WEB-INF/jsp/include/header.jsp" %>This will incline the literal text of header.jsp into your page. Of course, by doing that, you can no longer pass parameters to it, so you’d need to set that as a page context attribute (e.g. using <c:set>… but of course you can’t use <c:set> until you’ve done your include…).

Essentially, it’s not really worth the hassle. Taglib declarations are annoying boilerplate, but hard to get rid of.

 

您可能感兴趣的文章:
jsp动态include与静态include区别
include 指令和include 区别
JSP面试题与答案讲解
servlet与jsp基础教程(11)-JSP及语法概要
jsp常见问题二
php中include()和require()的区别
servlet与jsp基础教程(1)-Servlet和JSP概述
C# 静态方法与非静态方法的区别分析
修改DeDe标签Pagelist分页样式
php页面静态化的小例子

[关闭]
~ ~