include指令语法格式:
<%@ include file="XXX.jsp" %>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSP的include指令</title>
</head>
<body style="margin:0px;">
<%@ include file="top.jsp" %>
<table style="width:778px; height:279px; border:0; cellpadding:0; cellspacing:0;
background-image:url(images/center.JPG);">
<tr>
<td> </td>
</tr>
</table>
<%@ include file="copyright.jsp" %>
</body>
</html>
top.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<img src="images/banner.JPG">
copyright.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String copyright=" All Coypright © 2019 Hero 景易有限公司";
%>
<table style="width:778px; height:61px; border:0; cellpadding:0; cellspacing:0;
background-image:url(images/copyright.JPG);">
<tr>
<td> <%= copyright %></td>
</tr>
</table>
图片目录
效果:
注意点:
指令标识 include 为静态包含
A.jsp原样包含B.jsp 相当于 生成新的.jsp
所以:两者不能有相同名称的变量
还有table如果宽或高太多会导致图片显示多张平铺