rel="File-List" href="file:///C:/Users/ADMINI~1/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml" /> rel="themeData" href="file:///C:/Users/ADMINI~1/AppData/Local/Temp/msohtmlclip1/01/clip_themedata.thmx" /> rel="colorSchemeMapping" href="file:///C:/Users/ADMINI~1/AppData/Local/Temp/msohtmlclip1/01/clip_colorschememapping.xml" />
<%@ include file=”*.txt”%>成为静态包含,它是一条指令,何为静态包含呢?是指在JSP转换为Servlet时就已经把被包含的内容(*.txt)包含进来了,包含的时机是在转换的时候,在编译之前。静态包含还有一个特点,不能传参数。
TestBar.jsp
<%@ page contentType=”text/html; charset=gb2312”%>
<html><!- -*****TestBar.jsp*******- ->
<head>
<title>TestBar.jsp</title>
</head>
<body>
<table width=”100%”>
<tr><td><%@ include file=”TitleBar.jsp”%></td></tr>
//<tr><td><%@ include file=”TitleBar.jsp?user=123”%></td></tr>在编译期间传的参数没有意 义,这就是不能传参数。
<tr><td><%@ out.println(“<p>这是用户显示区<p>”);%></td></tr>
</table>
</body>
</html>
TitleBar.jsp
<%@ page contentType=”text/html; charset=gb2312”%>//如果出现乱码问题,这句话和包含页//面的这句话都要写上,并且要求一致
<table><!- - *******TitleBar.jsp**********- ->
<tr>
<td>
</td>
<td>
<%out.println(“Hi” + request.getParameter(“user”));%>
<%=new java.util.Date()%>
<%=request.getParameter(“user”)%>
</td>
</tr>
</table>
//包含页面与被包含页面访问同一个Request对象。如果在浏览器的地址输入栏里面输入http://localhost/test/TestBar.jsp?user=456/此时,页面将会输出user的值,几这样的穿参数//是可以的。