关于JSP中的静态包含与动态包含的理解!

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的值,几这样的穿参数//是可以的。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值