- 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
广告