Java include指令 使用示例

本文介绍了一个典型的JSP页面结构,展示了如何使用JSP指令来设置页面的基本属性,如何通过`include`指令引入头部和尾部文件,并呈现了主体内容区域的设计方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    
  </head>
  <body>
  	<!-- 引入 header  -->
    <%@include file="/WEB-INF/main/header.jsp" %>
    <!-- 主体内容 -->
   	<div style="border:solid 1px green; height: 50px; width: 300px;">
   		主要的内容2
   	</div>
   	<!-- 引入footer -->
    <%@include file="/WEB-INF/main/footer.jsp" %>
  </body>
</html>

<%@ page contentType="text/html;charset=UTF-8" %>
我的主页 | 新闻头条 | 电 视 剧 | 最新电影

<%@ page contentType="text/html;charset=UTF-8" %>
 关于我们 | 安全保障 | All Rights Reserved2


index_jsp.java
out.write("\r\n");
out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n");
out.write("<html>\r\n");
out.write("  <head>\r\n");
out.write("\t<meta http-equiv=\"pragma\" content=\"no-cache\"><meta http-equiv=\"cache-control\" content=\"no-cache\"><meta http-equiv=\"expires\" content=\"0\">    \r\n");
out.write("  </head>\r\n");
out.write("  <body>\r\n");
out.write("  \t<!-- 引入 header  -->\r\n");
out.write("    ");
out.write("\r\n");
out.write("我的主页 | 新闻头条 | 电 视 剧 | 最新电影\r\n");
out.write("\r\n");
out.write("    <!-- 主体内容 -->\r\n");
out.write("   \t<div style=\"border:solid 1px green; height: 50px; width: 300px;\">\r\n");
out.write("   \t\t主要的内容2\r\n");
out.write("   \t</div>\r\n");
out.write("   \t<!-- 引入footer -->\r\n");
out.write("    ");
out.write("\r\n");
out.write(" 关于我们 | 安全保障 | All Rights Reserved2\r\n");
out.write("\r\n");
out.write("  </body>\r\n");
out.write("</html>\r\n");


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值