include指令 (jsp)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41061455/article/details/82114881

使用include指令包含文件可以大大提高代码的重用性,而且也便于以后的维护和升级.

<%-- top.jsp --%>
<%@ page pageEncoding="utf-8"%>
<img src="images/banner.JPG">

<%-- index.jsp --%>

<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>使用文件包含include指令</title>
</head>
<body style="margin:0px;">
<%@ include file="top.jsp"%>
<table width="781" height="279" border="0" cellpadding="0" cellspacing="0" background="images/center.JPG">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<%@ include file="copyright.jsp"%>
</body>
</html>

<%-- copyright.jsp --%>

<%@ page pageEncoding="utf-8"%>
<%
String copyright="&nbsp;All Copyright &copy; 2009 吉林省科技有限公司";
%>
<table width="778" height="61" border="0" cellpadding="0" cellspacing="0" background="images/copyright.JPG">
  <tr>
    <td color="ff0000"> <%= copyright %></td>
  </tr>
</table>

猜你喜欢

转载自blog.csdn.net/qq_41061455/article/details/82114881