JSP中的include指令
include指令:向當前頁中插入一個靜態文件的內容。JSP 語法格式如下:
<%@ include file="relativeURL" %> 或
<%@ include file="相對位置" %>
<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() %>
包含一個靜態或動態文件.
JSP 語法格式如下:
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 … />]”指可以有多個“<jsp:param/>”標記。)
1.page="{relativeURL | <%=expression %>}"
參數為一相對路徑,或者是代表相對路徑的表達式。
2.flush="true"
這里必須使用flush="true",不能使用false值。而缺省值為false 。
3.<jsp:param name="parameterName" value="{parameterValue | <%= expression %> }" />
“<jsp:param>”用來傳遞一個或多個參數到指定的動態文件,能在一個頁面中使用多個“<jsp:param>”來傳遞多個參數,
<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>");
%>
posted on 2007-08-16 02:36 熱帶網海 閱讀(272) 評論(0) 編輯 收藏 所屬分類: JSP