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

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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值