JSTL Core < c:import > 标签
<c:import>
标签提供了 <include>
操作的所有的功能,同时也可以包含绝对URL。
例如,使用 import 标签允许包含来自不同的 Web 站点或 FTP 服务器的内容。
属性:
<c:import>
标签具有以下属性:
属性 | 描述 | 是否必需 | 默认值 |
---|---|---|---|
url | 检索和导入到页面的 URL | 是 | 无 |
context | / 紧随其后的是本地的一个web应用程序的名称 | 否 | 当前应用程序 |
charEncoding | 为导入数据使用的字符集 | 否 | ISO-8859-1 |
var | 存储导入文本的变量名 | 否 | 页面输出 |
scope | 存储导入文本的变量范围 | 否 | 页面 |
varReader | 显示 java.io.Reader 的另一个变量的名称 | 否 | 无 |
实例:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title><c:import> Tag Example</title> </head> <body> <c:import var="data" url="http://www.tutorialspoint.com"/> <c:out value="${data}"/> </body> </html>
上面的例子将从 tutorialspoint.com/index.htm 获取完整的内容,这将存储在变量数据中并最终输出出来。你可以自己尝试一下。