JSP注意事项
作者:互联网
源码
例子
footer.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<h1>我是Footer</h1>
header.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<h1>我是Header</h1>
jsp2.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%@include file="common/header.jsp"%>
<h1>网页主体</h1>
<%@include file="common/footer.jsp"%>
</body>
</html>
测试:
jsp标签
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%--
%@include会将两个页面合二为一 注意页面合并后的冲突(比如两个页面都定义了int i = 10 这种会报错)
--%>
<%@include file="common/header.jsp"%>
<h1>网页主体</h1>
<%@include file="common/footer.jsp"%>
<hr/>
<%--jsp标签
jsp:include 拼接页面 本质还是三个 推荐使用这种,这种不会出现上面的int i=10冲突的情况,因为本质还是三个页面
--%>
<jsp:include page="common/header.jsp"/>
<h1>网页主体</h1>
<jsp:include page="common/footer.jsp"/>
</body>
</html>
标签:主体,网页,Title,footer,源码,jsp,注意事项,JSP 来源: https://www.cnblogs.com/CnFallTime/p/15966806.html