What is the di开发者_运维技巧fference between Custom Tag Libraries and Core Tag Libraries in JSP?
Custom tag libraries are homegrown tag libraries. Core tag libraries are part of JSTL (JSP Standard Tag Library). You can find an overview of them all in the JSTL taglib documentation. It's the JSTL core one. It just offers a set of tags which are likely to be very commonly used to control the flow/output of a JSP page. Here's an extract of relevance:
JSTL core
Standard Syntax:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>XML Syntax:
<anyxmlelement xmlns:c="http://java.sun.com/jsp/jstl/core" />
JSTL 1.1 core library
Tag Library Information
- Display Name: JSTL core
- Version: 1.1
- Short Name: c
- URI: http://java.sun.com/jsp/jstl/core
Tag Summary
catchCatches any Throwable that occurs in its body and optionally exposes it.
chooseSimple conditional tag that establishes a context for mutually exclusive conditional operations, marked by<when>and<otherwise>
ifSimple 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
importRetrieves an absolute or relative URL and exposes its contents to either the page, a String in 'var', or a Reader in 'varReader'.
forEachThe basic iteration tag, accepting many different collection types and supporting subsetting and other functionality
forTokensIterates over tokens, separated by the supplied delimeters
outLike<%= ... >, but for expressions.
otherwiseSubtag of<choose>that follows tags and runs only if all of the prior conditions evaluated to 'false'
paramAdds a parameter to a containing 'import' tag's URL.
redirectRedirects to a new URL.
removeRemoves a scoped variable (from a particular scope, if specified).
setSets the result of an expression evaluation in a 'scope'
urlCreates a URL with optional query parameters.
whenSubtag of<choose>that includes its body if its condition evalutes to 'true'
See also:
- Java EE 5 tutorial - Using JSTL
- Java EE 5 tutorial - Custom tags in JSP pages
Note that Java EE 6 tutorial doesn't mention about them anywhere as JSP is considered to be "legacy". It's not officially deprecated though, the focus is just more put on Facelets, the successor of JSP, and the MVC framework JSF.
加载中,请稍侯......
精彩评论