:动态包含
第一种情况(包含的是html文件):
DynamicInclude.jsp:
- <%@pagecontentType="text/html;charset=gb2312"%>
- <html>
- <head>
- <title>动态包含title>
- head>
- <bodystylebodystyle="background-color:lightblue">
-
- <jsp:include page="header.html"flush="true"/>
-
- <tablebordertableborder="1" align="center">
- <tr>
- <td>姓名td><td>性别td><td>年龄td><td>爱好td>
- tr>
- <tr>
- <td>atd><td>btd><td>ctd><td>dtd>
- tr>
- table>
- body>
- html>
Header.html :
- <h2styleh2style="font-family:arial;color:red;font-size:25px;text-align:center">
- 动态包含的标题(HTML)
- h2>
运行之后,只生成一个servlet,和上面的代码对应如下:
- out.write("\r\n");
- out.write("\r\n");
- out.write("\t\r\n");
- out.write("\t\t动态包含\r\n");
- out.write("\t\r\n");
- out.write("\t\r\n");
- out.write("\r\n");
- out.write("\t\t");
- "color:#ff0000;">org.apache.jasper.runtime.JspRuntimeLibrary.include(request,response, "header.html", out, true);
- out.write("\r\n");
- out.write("\r\n");
- out.write("\t\t
\r\n");
- out.write("\t\t\t
\r\n");
- out.write("\t\t\t\t
姓名 | 性别 | 年龄 | 爱好 | \r\n");
- out.write("\t\t\t
\r\n");
- out.write("\t\t\t
\r\n");
- out.write("\t\t\t\t
a | b | c | d | \r\n");
- out.write("\t\t\t
\r\n");
- out.write("\t\t
\r\n");
- out.write("\t\r\n");
- out.write("