JSTL-taglib

来源:http://www.guanqinbiaoye.com 作者:计算机编程 人气:63 发布时间:2020-01-31
摘要:本文实例讲述了JSP自定义标签rtexprvalue属性。分享给大家供大家参考。具体如下: JSTL(JSP Standard Tag Lib) 其实以前也有写过自定义标签, 但是没有注意到过的用法,最近这几天又用上

本文实例讲述了JSP自定义标签rtexprvalue属性。分享给大家供大家参考。具体如下:

JSTL(JSP Standard Tag Lib)

其实以前也有写过自定义标签, 但是没有注意到过的用法, 最近这几天又用上自定义标签了, 突然发现的用法是有讲究的.

威尼斯网站,目录:

rtexprvalue的全称是 Run-time Expression Value, 它用于表示是否可以使用JSP表达式.

  • Core
  • Fmt
  • Function
  • SimpleTagSupport(jsp 自定义标签)
  • Tag File

当在标签里指定true时, 表示该自定义标签的某属性的值可以直接指定或者通过动态计算指定,

Core

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

 

为jstl的核心标签库 c.tld:

威尼斯游戏网站 1威尼斯游戏网站 2

<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
    version="2.1">

  <description>JSTL 1.1 core library</description>
  <display-name>JSTL core</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>c</short-name>
  <uri>http://java.sun.com/jsp/jstl/core</uri>

  <validator>
    <description>
        Provides core validation features for JSTL tags.
    </description>
    <validator-class>
        org.apache.taglibs.standard.tlv.JstlCoreTLV
    </validator-class>
  </validator>

  <tag>
    <description>
        Catches any Throwable that occurs in its body and optionally
        exposes it.
    </description>
    <name>catch</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable for the
exception thrown from a nested action. The type of the
scoped variable is the type of the exception thrown.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
    Simple conditional tag that establishes a context for
    mutually exclusive conditional operations, marked by
    &lt;when&gt; and &lt;otherwise&gt;
    </description>
    <name>choose</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
    <body-content>JSP</body-content>
  </tag>

  <tag>
    <description>
    Simple conditional tag, which evalutes its body if the
    supplied condition is true and optionally exposes a Boolean
    scripting variable representing the evaluation of this condition
    </description>
    <name>if</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.IfTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The test condition that determines whether or
not the body content should be processed.
        </description>
        <name>test</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    <type>boolean</type>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
resulting value of the test condition. The type
of the scoped variable is Boolean.        
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Retrieves an absolute or relative URL and exposes its contents
        to either the page, a String in 'var', or a Reader in 'varReader'.
    </description>
    <name>import</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class>
    <tei-class>org.apache.taglibs.standard.tei.ImportTEI</tei-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The URL of the resource to import.
        </description>
        <name>url</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
resource's content. The type of the scoped
variable is String.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
resource's content. The type of the scoped
variable is Reader.
        </description>
        <name>varReader</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the context when accessing a relative
URL resource that belongs to a foreign
context.
        </description>
        <name>context</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Character encoding of the content at the input
resource.
        </description>
        <name>charEncoding</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
    The basic iteration tag, accepting many different
        collection types and supporting subsetting and other
        functionality
    </description>
    <name>forEach</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class>
    <tei-class>org.apache.taglibs.standard.tei.ForEachTEI</tei-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Collection of items to iterate over.
        </description>
    <name>items</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>java.lang.Object</type>
        <deferred-value>
        <type>java.lang.Object</type>
        </deferred-value>
    </attribute>
    <attribute>
        <description>
If items specified:
Iteration begins at the item located at the
specified index. First item of the collection has
index 0.
If items not specified:
Iteration begins with index set at the value
specified.
        </description>
    <name>begin</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>int</type>
    </attribute>
    <attribute>
        <description>
If items specified:
Iteration ends at the item located at the
specified index (inclusive).
If items not specified:
Iteration ends when index reaches the value
specified.
        </description>
    <name>end</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>int</type>
    </attribute>
    <attribute>
        <description>
Iteration will only process every step items of
the collection, starting with the first one.
        </description>
    <name>step</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>int</type>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
current item of the iteration. This scoped
variable has nested visibility. Its type depends
on the object of the underlying collection.
        </description>
    <name>var</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
status of the iteration. Object exported is of type
javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested
visibility.
        </description>
    <name>varStatus</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
    Iterates over tokens, separated by the supplied delimeters
    </description>
    <name>forTokens</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
String of tokens to iterate over.
        </description>
    <name>items</name>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    <type>java.lang.String</type>
        <deferred-value>
        <type>java.lang.String</type>
        </deferred-value>
    </attribute>
    <attribute>
        <description>
The set of delimiters (the characters that
separate the tokens in the string).
        </description>
    <name>delims</name>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    <type>java.lang.String</type>
    </attribute>
    <attribute>
        <description>
Iteration begins at the token located at the
specified index. First token has index 0.
        </description>
    <name>begin</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>int</type>
    </attribute>
    <attribute>
        <description>
Iteration ends at the token located at the
specified index (inclusive).
        </description>
    <name>end</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>int</type>
    </attribute>
    <attribute>
        <description>
Iteration will only process every step tokens
of the string, starting with the first one.
        </description>
    <name>step</name>
    <required>false</required>
    <rtexprvalue>true</rtexprvalue>
    <type>int</type>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
current item of the iteration. This scoped
variable has nested visibility.
        </description>
    <name>var</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable for the
status of the iteration. Object exported is of
type
javax.servlet.jsp.jstl.core.LoopTag
Status. This scoped variable has nested
visibility.
        </description>
    <name>varStatus</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Like &lt;%= ... &gt;, but for expressions.
    </description> 
    <name>out</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Expression to be evaluated.
        </description>
        <name>value</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Default value if the resulting value is null.
        </description>
        <name>default</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Determines whether characters &lt;,&gt;,&amp;,'," in the
resulting string should be converted to their
corresponding character entity codes. Default value is
true.
        </description>
        <name>escapeXml</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>


  <tag>
    <description>
        Subtag of &lt;choose&gt; that follows &lt;when&gt; tags
        and runs only if all of the prior conditions evaluated to
        'false'
    </description>
    <name>otherwise</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
    <body-content>JSP</body-content>
  </tag>

  <tag>
    <description>
        Adds a parameter to a containing 'import' tag's URL.
    </description>
    <name>param</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.ParamTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the query string parameter.
        </description>
        <name>name</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Value of the parameter.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Redirects to a new URL.
    </description>
    <name>redirect</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.RedirectTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The URL of the resource to redirect to.
        </description>
        <name>url</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the context when redirecting to a relative URL
resource that belongs to a foreign context.
        </description>
        <name>context</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Removes a scoped variable (from a particular scope, if specified).
    </description>
    <name>remove</name>
    <tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
Name of the scoped variable to be removed.
        </description>
        <name>var</name>
        <required>true</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

 <tag>
    <description>
        Sets the result of an expression evaluation in a 'scope'
    </description>
    <name>set</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable to hold the value
specified in the action. The type of the scoped variable is
whatever type the value expression evaluates to.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Expression to be evaluated.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
        <deferred-value>
        <type>java.lang.Object</type>
        </deferred-value>
    </attribute>
    <attribute>
        <description>
Target object whose property will be set. Must evaluate to
a JavaBeans object with setter property property, or to a
java.util.Map object.
        </description>
        <name>target</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the property to be set in the target object.
        </description>
        <name>property</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Creates a URL with optional query parameters.
    </description>
    <name>url</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.UrlTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Name of the exported scoped variable for the
processed url. The type of the scoped variable is
String.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope for var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
URL to be processed.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the context when specifying a relative URL
resource that belongs to a foreign context.
        </description>
        <name>context</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
    Subtag of &lt;choose&gt; that includes its body if its
    condition evalutes to 'true'
    </description>
    <name>when</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.core.WhenTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The test condition that determines whether or not the
body content should be processed.
        </description>
        <name>test</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    <type>boolean</type>
    </attribute>
  </tag>

</taglib>

c.tld

 

用法:

标签

描述

Example

威尼斯游戏网站,<c:out>

用于在JSP中显示数据,就像<%= ... >

<c:out value="${headerV}" />

<c:set>

用于保存数据

<c:set var="headerV" value="foooooo" />

<c:remove>

用于删除数据

<c:remove var="headerV"/>

<c:catch>

用来处理产生错误的异常状况,并且将错误信息储存起来

<c:catch var="err"><% int i = 5/0; %></c:catch>

${err.message}${err}

<c:if>

与我们在一般程序中用的if一样

<c:if test="${!empty headerV}">***</c:if>

<c:choose>

本身只当做<c:when>和<c:otherwise>的父标签

<c:choose>

  <c:when test="">***</c:when>

  <c:when test="">***</c:when>

  <c:otherwise>***</c:otherwise>

</c:choose>

<c:when>

<c:choose>的子标签,用来判断条件是否成立

<c:otherwise>

<c:choose>的子标签,接在<c:when>标签后,当<c:when>标签判断为false时被执行

<c:import>

检索一个绝对或相对 URL,然后将其内容暴露给页面,和<jsp:include

一样

<c:import var="source" url="/index.html" charEncoding="UTF-8"/>
${source}

<c:forEach>

基础迭代标签,接受多种集合类型

<c:forEach var="v" items="${userList}" begin="2" end="6" step="1" varStatus="status">
  ${v.name}
  ${status.index} : ${status.count}
</c:forEach>

<c:forTokens>

根据指定的分隔符来分隔内容并迭代输出

<c:forTokens items="zhangsan,wangwu,lisi" var="v" varStatus="status" delims=",">
  ${v} - ${status.index + 1} : ${status.count}
</c:forTokens>

<c:url>

使用可选的查询参数来创造一个URL

<c:url var="jstl" value="./JspPage">
  <c:param name="bar" value="张三丰" />
  <c:param name="page" value="myJstl" />
</c:url>

<a href="${jstl}">跳转到myJstl.page</a>

<c:param>

用来给包含或重定向的页面传递参数

<c:redirect>

重定向至一个新的URL.直接跳转用在<c:if>中,比如一种情况直接跳转,另一种留在页面

<c:redirect url="" />

 

 

 

 

 

 

 

 

 

 

 

 

示例如下:

 

 

 

 

 

 

 

 

 

 

  select * from mytable order by nameid

 

 

 

 

 

 

 

 

 

当在标签里指定false时, 表示该自定义标签的某属性的值只能直接指定,  example as follow:
复制代码 代码如下:

Fmt

用来格式化并输出文本、日期、时间、数字。

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

 

fmt.tld文件:

威尼斯游戏网站 3威尼斯游戏网站 4

<?xml version="1.0" encoding="UTF-8" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    version="2.0">

  <description>JSTL 1.1 i18n-capable formatting library</description>
  <display-name>JSTL fmt</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>fmt</short-name>
  <uri>http://java.sun.com/jsp/jstl/fmt</uri>

  <validator>
    <description>
        Provides core validation features for JSTL tags.
    </description>
    <validator-class>
        org.apache.taglibs.standard.tlv.JstlFmtTLV
    </validator-class>
  </validator>

  <tag>
    <description>
        Sets the request character encoding
    </description>
    <name>requestEncoding</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.RequestEncodingTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
Name of character encoding to be applied when
decoding request parameters.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Stores the given locale in the locale configuration variable
    </description>
    <name>setLocale</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.SetLocaleTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
A String value is interpreted as the
printable representation of a locale, which
must contain a two-letter (lower-case)
language code (as defined by ISO-639),
and may contain a two-letter (upper-case)
country code (as defined by ISO-3166).
Language and country codes must be
separated by hyphen (-) or underscore
(_).        
    </description>
        <name>value</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Vendor- or browser-specific variant.
See the java.util.Locale javadocs for
more information on variants.
        </description>
        <name>variant</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of the locale configuration variable.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Specifies the time zone for any time formatting or parsing actions
        nested in its body
    </description>
    <name>timeZone</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.TimeZoneTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
The time zone. A String value is interpreted as
a time zone ID. This may be one of the time zone
IDs supported by the Java platform (such as
"America/Los_Angeles") or a custom time zone
ID (such as "GMT-8"). See
java.util.TimeZone for more information on
supported time zone formats.
        </description>
        <name>value</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Stores the given time zone in the time zone configuration variable
    </description>
    <name>setTimeZone</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.SetTimeZoneTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
The time zone. A String value is interpreted as
a time zone ID. This may be one of the time zone
IDs supported by the Java platform (such as
"America/Los_Angeles") or a custom time zone
ID (such as "GMT-8"). See java.util.TimeZone for
more information on supported time zone
formats.
        </description>
        <name>value</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable which
stores the time zone of type
java.util.TimeZone.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var or the time zone configuration
variable.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Loads a resource bundle to be used by its tag body
    </description>
    <name>bundle</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.BundleTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Resource bundle base name. This is the bundle's
fully-qualified resource name, which has the same
form as a fully-qualified class name, that is, it uses
"." as the package component separator and does not
have any file type (such as ".class" or ".properties")
suffix.
        </description>
        <name>basename</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Prefix to be prepended to the value of the message
key of any nested &lt;fmt:message&gt; action.
        </description>
        <name>prefix</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Loads a resource bundle and stores it in the named scoped variable or
        the bundle configuration variable
    </description>
    <name>setBundle</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.SetBundleTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
Resource bundle base name. This is the bundle's
fully-qualified resource name, which has the same
form as a fully-qualified class name, that is, it uses
"." as the package component separator and does not
have any file type (such as ".class" or ".properties")
suffix.
        </description>
        <name>basename</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable which stores
the i18n localization context of type
javax.servlet.jsp.jstl.fmt.LocalizationC
ontext.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var or the localization context
configuration variable.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Maps key to localized message and performs parametric replacement
    </description>
    <name>message</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.MessageTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Message key to be looked up.
        </description>
        <name>key</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Localization context in whose resource
bundle the message key is looked up.
        </description>
        <name>bundle</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable
which stores the localized message.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Supplies an argument for parametric replacement to a containing
        &lt;message&gt; tag
    </description>
    <name>param</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.ParamTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Argument used for parametric replacement.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Formats a numeric value as a number, currency, or percentage
    </description>
    <name>formatNumber</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.FormatNumberTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Numeric value to be formatted.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Specifies whether the value is to be
formatted as number, currency, or
percentage.
        </description>
        <name>type</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Custom formatting pattern.
        </description>
        <name>pattern</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
ISO 4217 currency code. Applied only
when formatting currencies (i.e. if type is
equal to "currency"); ignored otherwise.
        </description>
        <name>currencyCode</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Currency symbol. Applied only when
formatting currencies (i.e. if type is equal
to "currency"); ignored otherwise.
        </description>
        <name>currencySymbol</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Specifies whether the formatted output
will contain any grouping separators.
        </description>
        <name>groupingUsed</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Maximum number of digits in the integer
portion of the formatted output.
        </description>
        <name>maxIntegerDigits</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Minimum number of digits in the integer
portion of the formatted output.
        </description>
        <name>minIntegerDigits</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Maximum number of digits in the
fractional portion of the formatted output.
        </description>
        <name>maxFractionDigits</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Minimum number of digits in the
fractional portion of the formatted output.
        </description>
        <name>minFractionDigits</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable
which stores the formatted result as a
String.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Parses the string representation of a number, currency, or percentage
    </description>
    <name>parseNumber</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.ParseNumberTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
String to be parsed.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Specifies whether the string in the value
attribute should be parsed as a number,
currency, or percentage.
        </description>
        <name>type</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Custom formatting pattern that determines
how the string in the value attribute is to be
parsed.
        </description>
        <name>pattern</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Locale whose default formatting pattern (for
numbers, currencies, or percentages,
respectively) is to be used during the parse
operation, or to which the pattern specified
via the pattern attribute (if present) is
applied.
        </description>
        <name>parseLocale</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Specifies whether just the integer portion of
the given value should be parsed.
        </description>
        <name>integerOnly</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable which
stores the parsed result (of type
java.lang.Number).
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Formats a date and/or time using the supplied styles and pattern
    </description>
    <name>formatDate</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.FormatDateTag</tag-class>
    <body-content>empty</body-content>
    <attribute>
        <description>
Date and/or time to be formatted.
        </description>
        <name>value</name>
        <required>true</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Specifies whether the time, the date, or both
the time and date components of the given
date are to be formatted. 
        </description>
        <name>type</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Predefined formatting style for dates. Follows
the semantics defined in class
java.text.DateFormat. Applied only
when formatting a date or both a date and
time (i.e. if type is missing or is equal to
"date" or "both"); ignored otherwise.
        </description>
        <name>dateStyle</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Predefined formatting style for times. Follows
the semantics defined in class
java.text.DateFormat. Applied only
when formatting a time or both a date and
time (i.e. if type is equal to "time" or "both");
ignored otherwise.
        </description>
        <name>timeStyle</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Custom formatting style for dates and times.
        </description>
        <name>pattern</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Time zone in which to represent the formatted
time.
        </description>
        <name>timeZone</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable which
stores the formatted result as a String.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <description>
        Parses the string representation of a date and/or time
    </description>
    <name>parseDate</name>
    <tag-class>org.apache.taglibs.standard.tag.rt.fmt.ParseDateTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
        <description>
Date string to be parsed.
        </description>
        <name>value</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Specifies whether the date string in the
value attribute is supposed to contain a
time, a date, or both.
        </description>
        <name>type</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Predefined formatting style for days
which determines how the date
component of the date string is to be
parsed. Applied only when formatting a
date or both a date and time (i.e. if type
is missing or is equal to "date" or "both");
ignored otherwise.
        </description>
        <name>dateStyle</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Predefined formatting styles for times
which determines how the time
component in the date string is to be
parsed. Applied only when formatting a
time or both a date and time (i.e. if type
is equal to "time" or "both"); ignored
otherwise.
        </description>
        <name>timeStyle</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Custom formatting pattern which
determines how the date string is to be
parsed.
        </description>
        <name>pattern</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Time zone in which to interpret any time
information in the date string.
        </description>
        <name>timeZone</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Locale whose predefined formatting styles
for dates and times are to be used during
the parse operation, or to which the
pattern specified via the pattern
attribute (if present) is applied.
        </description>
        <name>parseLocale</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Name of the exported scoped variable in
which the parsing result (of type
java.util.Date) is stored.
        </description>
        <name>var</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
        <description>
Scope of var.
        </description>
        <name>scope</name>
        <required>false</required>
        <rtexprvalue>false</rtexprvalue>
    </attribute>
  </tag>

</taglib>

fmt.tld

 

用法:

标签 描述 Example
<fmt:formatNumber> 使用指定的格式或精度格式化数字  

<fmt:formatNumber var="cur" value="1235.6699" type="currency"/>

<fmt:formatNumber var="cur" value="56" type="percent" />
<fmt:formatNumber var="cur" value="000056" type="number" maxIntegerDigits="3" />

<fmt:parseNumber> 解析一个代表着数字,货币或百分比的字符串  
<fmt:formatDate> 使用指定的风格或模式格式化日期和时间  <fmt:formatDate value="${yearMonth}" pattern="yyyy-MM" />
<fmt:parseDate> 解析一个代表着日期或时间的字符串  <fmt:parseDate value="${item.expDate}" var="yearMonth" pattern="yyyy-MM-dd"/>
<fmt:bundle> 绑定资源  
<fmt:setLocale> 指定地区
<fmt:setLocale value="en_US"/>
<fmt:setBundle> 绑定资源  
<fmt:timeZone> 指定时区  
<fmt:setTimeZone> 指定时区  
<fmt:message> 显示资源配置文件信息  
<fmt:requestEncoding> 设置request的字符编码  

 

 

 

 

 

 

 

 

 

希望本文所述对大家的JSP程序设计有所帮助。

 

 

 

 

 

 

 

 

本文由威尼斯游戏网站发布于计算机编程,转载请注明出处:JSTL-taglib

关键词:

频道精选

最火资讯