jsp包含文件的兩種方法


 1 //第一種:include指令:當JSP轉換成Servlet時引入指定文件 <%@ page contentType="text/html; charset=GB2312" language="java" errorPage=""%>    
 2 <%@ include file="head.jsp"%>   
 3 <%@ include file="body.jsp"%>   
 4 <%@ include file="tail.jsp"%>   
 5 //第二種:<jsp:include>動作元素:當JSP頁面被請求時引入指定文件    
 6 <%@ page contentType="text/html; charset=GB2312" language="java" errorPage=""%>   
 7 <jsp:include page="head.jsp"/>   
 8 <jsp:include page="body.jsp"/>   
 9 <jsp:include page="tail.jsp"/>   
10   
11   
12 //第二種方法可以很方便的用<jsp:param>來向所包含頁傳遞參數,方法如下:    
13 <%@ page contentType="text/html; charset=GB2312" language="java" errorPage=""%>   
14 <jsp:include page="head.jsp"/>   
15 <jsp:include page="body.jsp">   
16 <jsp:param name="uid" value="username"/>   
17 <jsp:param name="pwd" value="password"/>   
18 </jsp:include>   
19 <jsp:include page="tail.jsp"/>   


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM