English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Le tag <c:url> formate l'URL en une chaîne de caractères et la stocke dans une variable.
Cette étiquette réécrit automatiquement l'URL lorsque nécessaire.
L'attribut var est utilisé pour stocker l'URL formatée.
Le tag <c:url> est une méthode optionnelle pour appeler la méthode response.encodeURL() ; sa véritable force réside dans le fait qu'il fournit une encodage d'URL approprié, y compris les paramètres spécifiés dans <c:param>.
<c:url var="<string>" scope="<string>" value="<string>" context="<string>"/>
<c:url> 标签具有以下属性:
属性 | 描述 | 是否必要 | 默认值 |
---|---|---|---|
value | 基础 URL | 是 | 无 |
context | 本地网络应用程序的名称 | 否 | 当前应用程序 |
var | 代表 URL 的变量名 | 否 | 打印到页面 |
scope | var 属性的作用域 | 否 | Page |
<%@ 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:url 标签示例</title> </head> <body> <h1<c:url> 示例 <Demo</h1> <a href="<c:url value="http://fr.oldtoolbag.com"/>"> 此链接通过 <c:url> 标签生成。 </a> </body> </html>
通过浏览器访问以上页面,然后查看源代码 或 按 F12 查看