您的位置:首页 > 其它

静态页面(动态页面)引入静态页面(动态页面)

2017-10-23 22:26 330 查看
1. 导入HTML页面

参考代码 :

第一种: div+$(“#page1”).load(“b.html”)

<body>

<div

id="page1"></div>

<div

id="page2"></div>

<script>

$("#page1").load("page/Page_1.html");

$("#page2").load("page/Page_2.html");

</script>

</body>

第二种: iframe

参考代码:

<head>

</head>

<body>

<div

id="page1">

<iframe

align="center"

width="100%"

height="170"

src="page/Page_1.html"

frameborder="no"

border="0"

marginwidth="0"

marginheight="0"

scrolling="no"></iframe>
</div>
<div

id="page2">
<iframe

align="center"

width="100%"

height="170"

src="page/Page_2.html"

frameborder="no"

border="0"

marginwidth="0"

marginheight="0"

scrolling="no"></iframe>

</div>

</body>

第三种:Object引入

参考代码:

<head>

<object

style="border:0px"

type="text/x-scriptlet"

data="page/Page_1.html"

width=100%

height=150>

</object>

</head>

第四种:import引入

参考代码:

<head>

<link

rel="import"

href="page/Page_1.html"

id="page1"></head><body>

<script>

console.log(page1.import.body.innerHTML);

</script>

</body>

第五种:

bootstrap的panel组件,或者easyui的window组件,有点类似这个效果;

参考:http://blog.csdn.net/arvin0/article/details/56839242

2.
引入JSP页面

第一种:JSTL
import

<c:import url="inlayingJsp.jsp"></c:import>

第二种:jsp
include指令

include指令告诉容器:复制被包含文件汇总的所有内容,再把它粘贴到这个文件中。

<%@ include file="inlayingJsp.jsp" %>
第三种:jsp include动作

<jsp:include page="inlayingJsp.jsp" flush="true"/>

注意:(1)include指令在转换时插入“Header.jsp”的源代码,而<jsp:include>动作在运行时插入“Header.jsp"的响应。

<%@include为静态包含,<%@include不论包含的是txt文本还是jsp文件,被包含的页面都不会从新编译。

<%@include为静态包含,包含了几个JSP转译成servlet时就会有 几 个 class文件,如果在jsp1定义了变量i同时在jsp2也定义了变量i那么你编 译都会通不过的,jsp容器会告诉你i重复定义了.

<jsp:include 为动态包含,<jsp:include 如包含jsp文件,这每次加载主页面的时候,被包含的页面都要重新编译。

就是说不管你包含了几个jsp页面转译成servlet时中有一个class文件

所以说对于<%@include要慎用!

(2)使用jstl标签时,一定要在jsp文件头加入以下代码:<%@taglib
prefix="c" uri="http://Java.sun.com/jsp/jstl/core"%>

参考:http://blog.csdn.net/fn_2015/article/details/70311495
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐