<c:import>标签提供所有的<include>动作的功能,但也允许包含的绝对URL。
例如,使用导入import标签允许列入的内容从不同的Web站点或FTP服务器。
<c:import>标签具有以下属性:
| 属性 | 描述 | 必须 | 默认 |
|---|---|---|---|
| url | URL to retrieve and import into the page | Yes | None |
| context | / followed by the name of a local web application | No | Current application |
| charEncoding | Character set to use for imported data | No | ISO-8859-1 |
| var | Name of the variable to store imported text | No | Print to page |
| scope | Scope of the variable used to store imported text | No | Page |
| varReader | Name of an alternate variable to expose java.io.Reader | No | None |
<%@ 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.codeinn.net"/>
<c:out value="${data}"/>
</body>
</html>
上面的例子可以获取完整的内容从yiibai.com/index.html 并将存储在变量数据是最终要打印出来。自己尝试一下。