JSP 外掛 action 元素有什麼用?
plugin action 用於將 Java 元件插入 JSP 頁面。它確定瀏覽器型別並根據需要插入<object> 或<embed> 標籤。
如果所需的外掛不存在,它會下載外掛,然後執行 Java 元件。Java 元件可以是小程式 (Applet) 或 JavaBean。
plugin action 具有多個屬性,這些屬性對應於用於格式化 Java 元件的常用 HTML 標籤。<param> 元素也可以用來向 Applet 或 Bean 傳送引數。
以下是使用 plugin action 的典型語法:
<jsp:plugin type = "applet" codebase = "dirname" code = "MyApplet.class"
width = "60" height = "80">
<jsp:param name = "fontcolor" value = "red" />
<jsp:param name = "background" value = "black" />
<jsp:fallback>
Unable to initialize Java Plugin
</jsp:fallback>
</jsp:plugin>如果您感興趣,可以使用一些小程式來嘗試此 action。一個新的元素,<fallback> 元素,可以用來指定在元件失敗時傳送給使用者的錯誤字串。
The <jsp:element> Action The <jsp:attribute> Action The <jsp:body> Action
<jsp:element>,<jsp:attribute> 和 <jsp:body> action 用於動態定義 XML 元素。 “動態”一詞很重要,因為它意味著 XML 元素可以在請求時生成,而不是在編譯時靜態生成。
以下是一個動態定義 XML 元素的簡單示例:
<%@page language = "java" contentType = "text/html"%> <html xmlns = "http://www.w3c.org/1999/xhtml" xmlns:jsp = "http://java.sun.com/JSP/Page"> <head> <title>Generate XML Element</title> </head> <body> <jsp:element name = "xmlElement"> <jsp:attribute name = "xmlElementAttr"> Value for the attribute </jsp:attribute> <jsp:body> Body for XML element </jsp:body> </jsp:element> </body> </html>
這將在執行時生成以下 HTML 程式碼:
<html xmlns = "http://www.w3c.org/1999/xhtml" xmlns:jsp = "http://java.sun.com/JSP/Page"> <head> <title>Generate XML Element</title> </head> <body> <xmlElement xmlElementAttr = "Value for the attribute"> Body for XML element </xmlElement> </body> </html>
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP