Preface

Comment

Declaration

Expression

Scriptlet

EL Expression

Directives

Attribute Directive

Include Directive

Page Directive

Tag Directive

Taglib Directive

Variable Directive

Standard Actions

<jsp:attribute>

<jsp:body>

<jsp:element>

<jsp:doBody>

<jsp:forward>

<jsp:getProperty>

<jsp:include>

<jsp:invoke>

<jsp:output>

<jsp:plugin>

<jsp:root>

<jsp:setProperty>

<jsp:text>

<jsp:useBean>

Tag Directive

Used for declaring custom tag properties.

JSP Syntax

<%@ tag   	
[ display-name="name of the tag file | display-name" ]
[ body-content="scriptless|tagdependent|empty" ]
[ dynamic-attributes="page-scoped attribute" ]
[ small-icon="relativeURL" ]
[ large-icon="relativeURL" ]
[ description="text" ]
[ example="text" ]
[ language="java" ]
[ import="{package.class | package.*} , ... " ]
[ pageEncoding="{characterSet | ISO-8859-1}" ]
[ isELIgnored="true|false" ]	
%>

OR

<jsp:directive.tag tagDirectiveAttrList />
where tagDirectiveAttrList is the same as the attribute list in the JSP syntax.

XML Syntax

<jsp:directive.tag tagDirectiveAttrList />

where tagDirectiveAttrList is the same as the attribute list in the JSP syntax.

Examples

This tag accepts an arbitrary number of attributes whose values are colors and outputs a bulleted list of the attributes colored according to the values:

<colored:colored color1="red" color2="yellow" color3="blue"/>

The following code implements the preceding tag. An arbitrary number of attributes whose values are colors are stored in a Map named by the dynamic-attributes attribute of the tag directive. The JSTL forEach tag is used to iterate through the Map and the attribute keys and colored attribute values are printed in a bulleted list.

<%@ tag dynamic-attributes="colorMap"%>	
<ul>	
<c:forEach var="color" begin="0" items="${colorMap}">	
<li>${color.key} = <font color="${color.value}">${color.value}</
font><li>	
</c:forEach>	
</ul>

Description

The tag directive is similar to the page directive in a JSP page, but applies to tag files instead of JSP pages. As with the page directive, a translation unit can contain more than one instance of the tag directive. All the attributes apply to the complete translation unit. However, there can be only one occurrence of any attribute or value defined by this directive in a given translation unit. With the exception of the import attribute, multiple attribute or value (re)definitions result in a translation error.

Attributes



宏飞网络是你学习web开发、测试web程序实例、和培养职业技能的首选网站。我们提供例子也许有些简单,但对理解基本概念有帮助。

我们尽量避免在教程、参考及例子中出现错误,但不能保证所有的内容都是正确的。

你使用本网站时,我们默认你已经阅读并接受了我们的隐私政策。

Copyright 2003-2011宏飞网络 版权所有