- JSP基礎教程
- JSP - 首頁
- JSP - 概述
- JSP - 環境搭建
- JSP - 架構
- JSP - 生命週期
- JSP - 語法
- JSP - 指令
- JSP - 動作
- JSP - 隱式物件
- JSP - 客戶端請求
- JSP - 伺服器響應
- JSP - HTTP狀態碼
- JSP - 表單處理
- JSP - 編寫過濾器
- JSP - Cookie處理
- JSP - 會話跟蹤
- JSP - 檔案上傳
- JSP - 日期處理
- JSP - 頁面重定向
- JSP - 點選計數器
- JSP - 自動重新整理
- JSP - 傳送郵件
- JSP高階教程
- JSP - 標準標籤庫
- JSP - 資料庫訪問
- JSP - XML資料
- JSP - JavaBean
- JSP - 自定義標籤
- JSP - 表示式語言
- JSP - 異常處理
- JSP - 除錯
- JSP - 安全性
- JSP - 國際化
- JSP有用資源
- JSP - 問答
- JSP - 快速指南
- JSP - 有用資源
- JSP - 討論
JSTL - XML <x:param> 標籤
<x:param>標籤與transform標籤一起使用,用於在XSLT樣式表中設定引數。
屬性
<x:param>標籤具有以下屬性:
| 屬性 | 描述 | 必填 | 預設值 |
|---|---|---|---|
| name | 要設定的XSLT引數的名稱 | 是 | 主體 |
| 值 | 要設定的XSLT引數的值 | 否 | 無 |
示例
考慮以下XSLT樣式表style.xsl。注意<xsl:param...>標籤和變數{$bgColor}的使用:
<?xml version = "1.0"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0">
<xsl:output method = "html" indent = "yes"/>
<xsl:param name = "bgColor"/>
<xsl:template match = "/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match = "books">
<table border = "1" width = "50%" bgColor = "{$bgColor}">
<xsl:for-each select = "book">
<tr>
<td><i><xsl:value-of select = "name"/></i></td>
<td><xsl:value-of select = "author"/></td>
<td><xsl:value-of select = "price"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
考慮以下JSP檔案,我們使用<x:transform>標籤內的<x:param>標籤定義bgColor的值:
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml" %>
<html>
<head>
<title>JSTL x:transform Tags</title>
</head>
<body>
<h3>Books Info:</h3>
<c:set var = "xmltext">
<books>
<book>
<name>Padam History</name>
<author>ZARA</author>
<price>100</price>
</book>
<book>
<name>Great Mistry</name>
<author>NUHA</author>
<price>2000</price>
</book>
</books>
</c:set>
<c:import url = "https://:8080/style.xsl" var = "xslt"/>
<x:transform xml = "${xmltext}" xslt = "${xslt}">
<x:param name = "bgColor" value = "grey"/>
</x:transform>
</body>
</html>
您將收到以下結果:
Books Info:
Padam History ZARA 100 Great Mistry NUHA 2000
jsp_standard_tag_library.htm
廣告