Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

tag

tag

JSP Standard Label LibraryJSP Standard Tag Library

The tag formats a URL into a string and then stores it in a variable.

This tag automatically rewrites URLs when needed.

The var attribute is used to store the formatted URL.

The tag is just an alternative way to call the response.encodeURL() method. Its real advantage lies in providing proper URL encoding, includingthe parameters specified in the tag.

Syntax format





property

The tag has the following attributes:

property Description Whether it is required Default value
value The base URL Is None
context The name of the local web application No The current application
var The name of the variable representing the URL No Print to page
scope The scope of the var attribute No Page

Example Demonstration



<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>





c:url 标签实例





    

实例 Demo

    ">      这个链接通过 标签生成。     

Access the above page through a browser, then view the source code, which is displayed as follows:


JSP Standard Label LibraryJSP Standard Tag Library