首页 > 代码库 > jsp动态包含和静态包含
jsp动态包含和静态包含
静态包含:先把动态代码重新组合,再生成静态页面
动态包含:各个代码各自生成自己的静态页面,然后再将各自生成的静态组合起来
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>include指令(静态包含),它包含的所有jsp编译成一个servlet</title>
</head>
<body>
<%@include file="/public/head.jsp" %>
aaaaaaaaaaa<br/>
<%@include file="/public/foot.jsp" %>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>动态包含(运行时包含),</title>
</head>
<body>
<%
request.getRequestDispatcher("/public/head.jsp").include(request,response);
%>
<%
response.getWriter().write("aaaaaaaaaaaaaa<br/>");
%>
<%
request.getRequestDispatcher("/public/head.jsp").include(request,response);
%>
</body>
</html>
jsp动态包含和静态包含