JSP reference (3) Directive element [direve VE]

Source: Internet
Author: User
Tags tld
JSP reference (3) Directive element [direve VE] <% @ Attribute %> description
This command can only be used in tag files. It declares the attributes supported by the Tag file.
 
Syntax
<% @ Attribute name = "attrname" [description = "Description"]
[Required = "True | false"] [fragment = "True | false" | [type = "attrdatatype"]
[Rtexprvalue = "True | false"] %>

 
Attribute
Default Name Description
The description does not have a description of the attribute. It can be provided to webpage designers through webpage design tools.
Fragment false true indicates that the property is a JSP code segment, and false indicates that the property is converted to the type specified by the Type property.
No attribute name for name
Required false true if this attribute is required
Rtexdprvalue true if the attribute must be provided as a static text value, false. If the value is true, the attribute value can be provided by El or Java expressions.
Type string attribute data type. Basic types are not supported.
 
 
Remarks
When the fragment attribute is used, the rtexprvalue and type attributes cannot be used any more. For a segment, the runtime expression value is always accepted, and the type is fixed to javax. servlet. jsp. tagext. jspfragment.
 
Example
<% @ Attribute name = "date" type = "Java. util. Date" %>
<% @ Attribute name = "pattern" fragment = "true" %>

<% @ Include %> description
Contains a static file, merges its content with the contained page, and then converts the combined result into a page implementation class.
 
Syntax
<% @ Indlude file = "pageorcontextrelativepath" %>

 
Attribute
Default Name Description
File does not have the relative URI path or Context Relative Path of the page containing the file.
 
 
Remarks
A page can have multiple include commands. The included page and all included pages constitute the so-called JSP compilation unit.
 
Example
<% @ Include file = "header.html" %>

<% @ Page %> description
This command can only be used on JSP pages. It defines page-dependent attributes, such as scripting language, error pages, and buffer requirements.
 
Syntax
<% @ Page [autoflush = "True | false"] [buffer = "8kb | nnkb | none"]
[Contenttype = "mimetype"] [errorpage = "pageorcontextrelativepath"]
[Extends = "classname"] [import = "packagelist"] [info = "info"]
[Iselignored = "True | false"] [iserrorpage = "True | false"]
[Isthreadsafe = "True | false"] [Language = "Java | language"]
[Pageencoding = "encoding"] [session = "True | false"] %>

 
Attribute
Default Name Description
Autoflush true indicates whether to automatically refresh the output. If it is set to false, an exception is thrown when the buffer is full.
8 KB buffer specifies the page buffer size
The MIME type of the response generated by the contenttype text/HTML or text/XML page. It may also include the response character set. For JSP pages, the default value is text/html. for JSP documents, the default value is text/XML.
Error Page: The target page to jump to when no page code throws an exception
Extends does not have a base class for the compilation unit of JSP pages. It must be implemented as a jsppage or httpjsppage interface.
The import does not have a Java package imported on the page. It has unique attributes that can be repeated.
Info no page description text
Iselignored false whether to ignore the El expression
Whether the isthreadsafe true page can provide services for parallel requests
Language Java Page scripting language, which currently supports Java
For details about pageencoding, refer to the description for JSP page encoding. Regular pages are ISO-8859-1 by default, and for JSP document documents, UTF-8 by default
Session true whether to enable user sessions on the page
 
 
Remarks
The compilation unit can have multiple page commands, but all the import and pageencoding attributes will be merged. Only one page instruction is allowed for files in the compilation unit.
 
Example
<% @ Page Language = "Java" contexttype = "text/html; charset = gb2312" %>
<% @ Page import = "Java. util. *, java. Text. *" %>
<% @ Page import = "Java. SQL. Date" %>

<% @ Tag %> description
It can only be used in the Tag file. It defines the attributes of the file and the attributes of the corresponding custom tag.
 
Syntax
<% @ Tag [body-content = "Empty | scriptless | tagdependent"]
[Description = "Description"] [display-name = "displayname"]
[Dynamic-attributes = "attrcollvar"] [Example = "example"]
[Import = "packagelist"] [iselignored = "True | false"]
[Language = "Java"] [large-Icon = "largeiconpath"]
[Pageencoding = "encoding"] [small-Icon = "smalliconpath"] %>

 
Attribute
Default Name Description
Body-content scriptless defines the action body type
Description: No text description.
Display-Name: name displayed in the environment without ide
Dynamic-attributes does not specify a variable for saving undeclared attribute values. It is a map, the key is the attribute name, and the value is the attribute value.
Example does not show how to use tags
The import does not have a Java package imported on the page. It has unique attributes that can be repeated.
Iselignored false whether to ignore the El expression
Language Java Page scripting language, which currently supports Java
Lareg-Icon does not have the path of the big icon (32*32) used in the IDE environment
The pageencoding ISO-8859-1 is used to encode the label File
Small-Icon does not have the path of the small icon (16*16) used in the IDE environment
 
 
Remarks
For jsp2.0 containers, the default value of iselignored is false. For earlier JSP containers, this value is true.
 
Example
<% @ TAG body-content = "empty" dynamic-attributes = "dynattrs" %>

<% @ Taglib %> description
Declare a tag library used on the page
 
Syntax
<% @ Taglib prefix = "prefix" [uri = "tagliburi" | tagdir = "contextrelatvepath"] %>

 
Attribute
Default Name Description
The prefix does not specify the prefix of the custom tag library.
The URI does not have any library symbol defined in the library TLD or the application web. xml file, or it can be the page relative URI path or Context Relative URI path of the library TLD file or jar file.
The Context Relative Path of the directory where tagdir does not contain the flag file, starting with/WEB-INF/tags
 
 
Remarks
It can be used on the JSP page and Tag file page.
 
Example
<% @ Taglib prefix = "ora" uri = "orataglib" %>
<% @ Taglib prefix = "C" uri = "http://java.sun.com/jstl/core" %>
<% @ Page prefix = "mylib" tagdir = "/WEB-INF/tags/mylib" %>

<% @ Variable %> description
It can only be used in Tag file. It declares that the Tag file is a variable provided by the page.
 
Syntax
<% @ Variable name-given = "attrandvarname" | Name-from-attribute = "attrname"
Alias = "varname" [declare = "True | false"] [description = "Description"]
[Scope = "at_end | at_begin | nested"] [variable-class = "vartype"] %>

 
Attribute
Default Name Description
Name-given the unlabeled file is used to provide the name of the variable whose creation value is
Name-from-attribute: the name of the created variable is specified by the attribute.
The alias unlabeled file is used to save the name of the local page scope variable for the created value. The container copies the value of this local variable to a page scope variable on the call page.
Declare true specifies the variable used to save the undeclared attribute value. It is a map, the key is the attribute name, and the value is the attribute value.
Description no description
Scope nested scope of the imported variable
Variable-class string full path of the verification class
 
 
Remarks
The name-from-attribute must be used with alias, but cannot be used with name-given.
 
Example
<% @ Variable name-from-attribute = "Var" alias = "current"
Variable-class = "Java. util. Date" Scope = "at_end" %>
<% @ Attribute name = "Var" required = "true" rtexprvalue = "false" %>


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.