English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Le tag <c:import> offre toutes les fonctionnalités des balises de comportement <jsp:include>, tout en permettant également l'inclusion d'URL absolues.
Par exemple, l'utilisation du tag <c:import> peut inclure du contenu de pages Web différentes sur un serveur FTP.
<c:import url="<string>" var="<string>" scope="<string>" varReader="<string>" context="<string>" charEncoding="<string>"/>
Les attributs du tag <c:import> sont les suivants :
Attribut | Description | Nécessaire ou non | Valeur par défaut |
---|---|---|---|
url | L'URL des ressources à importer, qui peut être un chemin relatif ou absolu, et peut importer des ressources d'autres hôtes | 是 | 无 |
context | 当使用相对路径访问外部context资源时,context指定了这个资源的名字。 | 否 | 当前应用程序 |
charEncoding | 所引入的数据的字符编码集 | 否 | ISO-8859-1 |
var | 用于存储所引入的文本的变量 | 否 | 无 |
scope | var属性的作用域 | 否 | page |
varReader | 可选的用于提供java.io.Reader对象的变量 | 否 | 无 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title>c:import 标签示例</title> </head> <body> <c:import var="data" url="http://fr.oldtoolbag.com"/> <c:out value="${data}"/> </body> </html>
以上程序将会打印http://fr.oldtoolbag.com"页面的源代码,您可以自己动手尝试一下。