页面之间的包含

head.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<p>头部信息</p>
</body>
</html>

 

footer.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
尾部
</body>
</html>

head.html和footer.jsp在common包下

 

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<%-- <h1>静态包含</h1>
<%@ include file="common/head.html" %>
<p>content</p>
<%@ include file="common/footer.jsp" %> --%>

 


<h1>动态包含</h1>
<jsp:include page="common/head.html"/>
<p>content</p>
<jsp:include page="common/footer.jsp"/>
</body>
</html>

 

注:静态包含是把jsp页面合在一起在转成一个servlet在编译,动态包含是各自的servlet解释成servlet后再编译的

posted @ 2017-02-20 23:03  小拽A  阅读(190)  评论(0编辑  收藏  举报