jsp框架frameset和frame的区别和用法(转:zph_0629的日志 - 网易博客)

【注】可以通过对框架的命名,实现jsp页面的target设置

首先搞清楚框架的两个标签:frameset和frame.
 1.frameset:声明页面是采用了框架技术

 Java代码:

<frameset rows="60,*" frameborder="1" border="0" bordercolor="#000FFF" framespacing="1">   
lt;/frameset>  

rows="60,*"是把页面分为上下两个部分,rows="*,*,*"是把页面分成上中下3个部分 

cols="60,*"是把页面分为左右两个部分,以此类推....省略其中方法和属性描述
2.frame:简单的说framset是页面分布的结构,那么frame就是结构中的内容了

把页面分为上下两个部分,下部分又分成左右两个小模块组成,代码如下:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>   
<%   
String path = request.getContextPath();   
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";   
%>   
  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">   
<html>   
  <head>   
    <base href="<%=basePath%>">   
       
    <title>例子</title>   
       
    <meta http-equiv="pragma" content="no-cache">   
    <meta http-equiv="cache-control" content="no-cache">   
    <meta http-equiv="expires" content="0">       
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">   
    <meta http-equiv="description" content="This is my page">   
    <!--   
    <link rel="stylesheet" type="text/css" href="styles.css">   
    -->   
  
  </head>   
  <frameset rows="70,*" cols="*" frameborder="No" border="0"  
        framespacing="1">   
        <frame   
            src="inc/top.jsp"  
            name="topFrame" scrolling="No" noresize="noresize" id="topFrame"  
            title="topFrame" />   
           
        <frameset cols="160,*" frameborder="No" border="0" framespacing="1">   
            <frame   
                src="inc/menu.jsp"  
                   
                src="inc/controlMenu.jsp"    
                name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame"  
                title="leftFrame" />   
            <frame   
                src="exclusiveUpdateCar.jsp"  
                name="mainFrame" noresize="noresize" id="mainFrame" title="mainFrame" />   
<!--注意id="mainFrame"和 menu.jsp中的target="mainFrame"..看这就明白了。意思就是menu.jsp中的target="mainFrame"中的网页显示在id="mainFrame"的部分中来-->     
        </frameset>   
    </frameset>   
  <noframes>   
        <body>   
        </body>   
    </noframes>   
</html>

 

posted @ 2013-05-01 11:10  裴佩  阅读(661)  评论(0编辑  收藏  举报