jsp:include 只不过是一个不同于 include
的伪指令而已。 jsp:include
的优点在于:它总是会检查所含文件中的变化。而jsp include则不会, 可以认为是静态包含。下面是两则区别的代码:
1.jsp include
<%@ page language="java" contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>JSP include element test</title>
</head>
<body>
This content is statically in the main JSP file.<br />
<%@ include file="included.html" %>
</body>
</html>
2.jsp:include
同上面是一个页面,只不过这里转成使用 jsp:include
标记
<%@ page language="java" contentType="text/html;charset=gb2312" %>
<html>
<head>
<title>JSP include element test</title>
</head>
<body>
This content is statically in the main JSP file.<br />
<jsp:include page="included.html" flush="true" />
</body>
</html>