1. 程式人生 > >JSP指令

JSP指令

per 名稱 art 結束 cte read taglib 如何 ava

---恢復內容開始---

JSP指令提供指導和指示的容器,告訴它如何處理JSP中處理的某些方面。

一個JSP指令影響Servlet類的整體結構。它通常具有以下形式:

<%@ directive attribute="value" %>
指令可以有多個屬性,你可以列出下來為鍵 - 值對,並用逗號分隔。

@符號和指令名稱,和最後的屬性和閉合 %> 之間的空白,是可選的。

有三種類型的指令標簽:

指令 描述
<%@ page ... %> 定義頁面相關的屬性,例如腳本語言,頁面錯誤,和緩沖的要求。
<%@ include ... %> 包括在轉換階段的文件。
<%@ taglib ... %> 聲明一個標簽庫,含自定義操作,在頁面中使用 page 指令:
page指令用於提供指示,涉及到當前JSP頁面的容器。你可以在JSP頁面的任何地方代碼頁指令。按照慣例,page指令進行編碼的JSP頁面的頂部。

以下是page指令的基本語法:

<%@ page attribute="value" %>
您可以編寫XML相當於上面的語法如下:

<jsp:directive.page attribute="value" />
屬性:
以下是page指令相關聯的屬性的列表:

屬性 目的
buffer Specifies a buffering model for the output stream.
autoFlush Controls the behavior of the servlet output buffer.
contentType Defines the character encoding scheme.
errorPage Defines the URL of another JSP that reports on Java unchecked runtime exceptions.
isErrorPage Indicates if this JSP page is a URL specified by another JSP page‘s errorPage attribute.
extends Specifies a superclass that the generated servlet must extend
import Specifies a list of packages or classes for use in the JSP as the Java import statement does for Java classes.
info Defines a string that can be accessed with the servlet‘s getServletInfo() method.
isThreadSafe Defines the threading model for the generated servlet.
language Defines the programming language used in the JSP page.
session Specifies whether or not the JSP page participates in HTTP sessions
isELIgnored Specifies whether or not EL expression within the JSP page will be ignored.
isScriptingEnabled Determines if scripting elements are allowed for use.
查看更詳細的有關在上述所有屬性Page 指令.

include指令:
include指令用於包括在轉換階段的文件。這個指令告訴容器在轉換階段合並的其他外部文件的內容和當前的JSP。您可能代碼include指令在JSP頁面的任何地方。

該指令的一般用法形式如下:

<%@ include file="relative url" >
在include指令的文件名實際上是一個相對URL。如果你只是指定一個沒有關聯的路徑的文件名,則JSP編譯器假定該文件在同一目錄下的JSP。

您可以編寫XML相當於上面的語法如下:

<jsp:directive.include file="relative url" />
查看更詳細的有關include指令在 Include 指令.

taglib 指令:
在JavaServer頁面API允許您定義自定義看起來像HTML或XML標簽,一個標簽庫是一套實現自定義行為的用戶自定義標簽的JSP標簽。

taglib指令聲明JSP頁面中使用一組自定義標簽,標識庫的位置,並提供用於識別自定義標簽在JSP頁面中的一種手段。

taglib指令如下的語法如下:

<%@ taglib uri="uri" prefix="prefixOfTag" >
uri屬性值解析為一個位置的容器理解和前綴屬性通知容器哪些標記位的是自定義操作。

您可以編寫XML相當於上面的語法如下:

<jsp:directive.taglib uri="uri" prefix="prefixOfTag" />

---恢復內容結束---

JSP指令提供指導和指示的容器,告訴它如何處理JSP中處理的某些方面。

一個JSP指令影響Servlet類的整體結構。它通常具有以下形式:

<%@ directive attribute="value" %>
指令可以有多個屬性,你可以列出下來為鍵 - 值對,並用逗號分隔。

@符號和指令名稱,和最後的屬性和閉合 %> 之間的空白,是可選的。

有三種類型的指令標簽:

指令 描述
<%@ page ... %> 定義頁面相關的屬性,例如腳本語言,頁面錯誤,和緩沖的要求。
<%@ include ... %> 包括在轉換階段的文件。
<%@ taglib ... %> 聲明一個標簽庫,含自定義操作,在頁面中使用 page 指令:
page指令用於提供指示,涉及到當前JSP頁面的容器。你可以在JSP頁面的任何地方代碼頁指令。按照慣例,page指令進行編碼的JSP頁面的頂部。

以下是page指令的基本語法:

<%@ page attribute="value" %>
您可以編寫XML相當於上面的語法如下:

<jsp:directive.page attribute="value" />
屬性:
以下是page指令相關聯的屬性的列表:

屬性 目的
buffer Specifies a buffering model for the output stream.
autoFlush Controls the behavior of the servlet output buffer.
contentType Defines the character encoding scheme.
errorPage Defines the URL of another JSP that reports on Java unchecked runtime exceptions.
isErrorPage Indicates if this JSP page is a URL specified by another JSP page‘s errorPage attribute.
extends Specifies a superclass that the generated servlet must extend
import Specifies a list of packages or classes for use in the JSP as the Java import statement does for Java classes.
info Defines a string that can be accessed with the servlet‘s getServletInfo() method.
isThreadSafe Defines the threading model for the generated servlet.
language Defines the programming language used in the JSP page.
session Specifies whether or not the JSP page participates in HTTP sessions
isELIgnored Specifies whether or not EL expression within the JSP page will be ignored.
isScriptingEnabled Determines if scripting elements are allowed for use.
查看更詳細的有關在上述所有屬性Page 指令.

include指令:
include指令用於包括在轉換階段的文件。這個指令告訴容器在轉換階段合並的其他外部文件的內容和當前的JSP。您可能代碼include指令在JSP頁面的任何地方。

該指令的一般用法形式如下:

<%@ include file="relative url" >
在include指令的文件名實際上是一個相對URL。如果你只是指定一個沒有關聯的路徑的文件名,則JSP編譯器假定該文件在同一目錄下的JSP。

您可以編寫XML相當於上面的語法如下:

<jsp:directive.include file="relative url" />
查看更詳細的有關include指令在 Include 指令.

taglib 指令:
在JavaServer頁面API允許您定義自定義看起來像HTML或XML標簽,一個標簽庫是一套實現自定義行為的用戶自定義標簽的JSP標簽。

taglib指令聲明JSP頁面中使用一組自定義標簽,標識庫的位置,並提供用於識別自定義標簽在JSP頁面中的一種手段。

taglib指令如下的語法如下:

<%@ taglib uri="uri" prefix="prefixOfTag" >
uri屬性值解析為一個位置的容器理解和前綴屬性通知容器哪些標記位的是自定義操作。

您可以編寫XML相當於上面的語法如下:

<jsp:directive.taglib uri="uri" prefix="prefixOfTag" />

JSP指令