include指令:向當(dāng)前頁(yè)中插入一個(gè)靜態(tài)文件的內(nèi)容。
JSP 語(yǔ)法格式如下:
<%@ include file="relativeURL" %> 或
<%@ include file="相對(duì)位置" %>
<html>
<head>
<title>test</title>
</head>
<body bgcolor="white">
<font color="blue">
The current date and time are
<%@ include file=“peixun2.6.1.jsp" %>
</font>
</body>
</html>
<%@ page import="java.util.*" %>
<%=(new java.util.Date() ).toLocaleString() %>
包含一個(gè)靜態(tài)或動(dòng)態(tài)文件.
JSP 語(yǔ)法格式如下:
1.<jsp:include page="{relativeURL | <%=expression%>}" flush="true" />
2.<jsp:include page="{relativeURL | <%=expression %>}" flush="true" >
<jsp:param name="parameterName" value="{parameterValue | <%= expression %>}" />
[<jsp:param …/>]
</jsp:include>
(“[<jsp:param … />]”指可以有多個(gè)“<jsp:param/>”標(biāo)記。)
1.page="{relativeURL | <%=expression %>}"
參數(shù)為一相對(duì)路徑,或者是代表相對(duì)路徑的表達(dá)式。
2.flush="true"
這里必須使用flush="true",不能使用false值。而缺省值為false 。
3.<jsp:param name="parameterName" value="{parameterValue | <%= expression %> }" />
“<jsp:param>”用來(lái)傳遞一個(gè)或多個(gè)參數(shù)到指定的動(dòng)態(tài)文件,能在一個(gè)頁(yè)面中使用多個(gè)“<jsp:param>”來(lái)傳遞多個(gè)參數(shù),
<html>
<head>
<title>peixun.2.10.jsp</title>
</head>
<body>
<jsp:include page="peixun2.10.1.jsp" flush="true" >
<jsp:param name="User" value="HiFi King" />
</jsp:include>
</body>
</html>
<%
String username;
username=request.getParameter("User");
out.println("Username is "+username+"<br>");
%>