偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Struts標(biāo)簽庫中的HTML標(biāo)簽

開發(fā) 后端
為了更容易、更快速地進(jìn)行開發(fā),Struts提供了功能同其它JSP標(biāo)簽庫類似的五個(gè)標(biāo)簽庫,即:HTML 、Bean、Logic、Template和Nested。下面我們來一一介紹這五個(gè)標(biāo)簽的作用和用法。

一. Struts標(biāo)簽庫中的HTML標(biāo)簽

HTML標(biāo)簽庫主要用來顯示HTML元素,如果不用這種方法,你就必須用HTML標(biāo)簽來指定它們。從表面上看,這個(gè)標(biāo)簽庫很簡單。但是通過深入研究,我們就會(huì)發(fā)現(xiàn)它很強(qiáng)大。例如,它可以為我們?cè)贖TML表單的

一個(gè)特定輸入元素中放置重點(diǎn)內(nèi)容生成JavaScript,或?yàn)榭蛻舳溯斎腧?yàn)證生成腳本。而且,你可以用它通過一行代碼來處理錯(cuò)誤。然而,在將這個(gè)標(biāo)簽庫用于你的Struts應(yīng)用程序前,你需要做些簡單的準(zhǔn)備工作。

配置應(yīng)用程序來運(yùn)用標(biāo)簽庫

在運(yùn)用Struts HTML標(biāo)簽庫前,你需要通過三個(gè)步驟來配置一個(gè)Struts應(yīng)用程序。

1. 在部署描述符(web.xml文件)中注冊(cè)標(biāo)簽庫,告訴servlet容器有關(guān)Struts HTML標(biāo)簽庫的情況,以及在哪里可以找到標(biāo)簽庫的TLD文件,代碼如下:

/WEB-INF/struts-html.tld

< /TAGLIB-URI>/WEB-INF/struts-html.tld

< /TAGLIB-LOCATION>2. 要確定將struts-html.tld文件復(fù)制到WEB-INF目錄中。你不用擔(dān)心標(biāo)簽庫類文件,因?yàn)樗鼈円呀?jīng)包含在struts.jar文件中了。

3. 在運(yùn)用標(biāo)簽庫的每個(gè)JSP頁面中,插入下面的指示符:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

HTML標(biāo)簽庫包含幾個(gè)很容易使用的獨(dú)立的標(biāo)簽:

< html:html>標(biāo)簽

< html:html>標(biāo)簽是HTML標(biāo)簽庫中最容易的標(biāo)簽。它有兩個(gè)屬性:locale和xhtml,兩者都不是必需的。

e.g. HelloWorld-html:

建立一個(gè)JSP頁面welcome.jsp,輸入如下內(nèi)容:

< %@ taglib uri="/WEB-INF/struts- html.tld" prefix="html" %>
< ?xml:namespace prefix = html />< html:html locale="true">



Hello World!

中的locale屬性在生成的HTML頁面中被轉(zhuǎn)換成了。生

成的結(jié)果取決于Struts應(yīng)用程序所位于的服務(wù)器的locale。如果你將應(yīng)用程序部署到一個(gè)不同locale的服務(wù)器,你不需要改變代碼。Locale會(huì)自動(dòng)調(diào)整。

< html:base>標(biāo)簽

< html:base>標(biāo)簽顯示一個(gè)HTML元素,用一個(gè)href屬性表示所包含的JSP頁面的絕對(duì)位置。只有當(dāng)這個(gè)

標(biāo)簽是內(nèi)嵌在一個(gè)head標(biāo)簽部分時(shí),它才有效。e.g. HelloWorld-base:

< %@ taglib uri="/WEB-INF/struts- html.tld" prefix="html" %>



< html:base>< /html:base>


Hello World!

< /html:html>

< html:base>標(biāo)簽會(huì)轉(zhuǎn)換成:




< BASE href="

< html:link>標(biāo)簽

< html:link>標(biāo)簽會(huì)生成一個(gè)超鏈接。
e.g. < html:link page="/index.jsp">Index< /html:link>
會(huì)轉(zhuǎn)換成:Index

< html:errors>標(biāo)簽

< html:errors>標(biāo)簽的易于使用性通常會(huì)掩蓋其真正的強(qiáng)大功能。通過一個(gè)簡單的< html:errors>< /html:errors>標(biāo)簽,你就可以在一個(gè)JSP頁面上顯示完全自定義的錯(cuò)誤信息。這個(gè)標(biāo)簽檢查Request對(duì)象的屬性集合來查找一個(gè)reserved key。如果它找到一個(gè)reserved key,它就假設(shè)這個(gè)key是一個(gè) String、或是一個(gè)String數(shù)組(它包含在模塊的MessageResources中查找的message keys)、或是類型為org.apache.struts.action.ActionErrors的一個(gè)對(duì)象。

如果在應(yīng)用程序資源中存在相應(yīng)的信息,那么就可以用下面這些可選的message keys:
errors.header:相應(yīng)的信息在錯(cuò)誤信息的單獨(dú)列表前顯示。
errors.footer:相應(yīng)的信息在錯(cuò)誤信息的單獨(dú)列表后顯示。
errors.prefix:相應(yīng)的信息在錯(cuò)誤信息的單獨(dú)列表前顯示。
errors.suffix:相應(yīng)的信息在錯(cuò)誤信息的單獨(dú)列表后顯示。


二. logic 標(biāo)簽

1、定義標(biāo)簽文件(web.xml)


/tags/struts-logic
/WEB-INF/struts-logic.tld

2、引用標(biāo)簽文件(jsp文件)

<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

3、標(biāo)簽文件說明(struts-logic.tld)

(1)empty標(biāo)簽

類名:org.apache.struts.taglib.logic.EmptyTag
標(biāo)簽體:bodycontent=JSP
引用logic:empty
屬性 attribute:name,property,scope
功能:判斷對(duì)象的值是否為空

(2)equal

類名:org.apache.struts.taglib.logic.EqualTag
標(biāo)簽體:bodycontent=JSP
引用logic:equal
屬性 attribute:cookie,header,name,parameter,property,scope,value
功能:等于比較符

(3) forward

org.apache.struts.taglib.logic.ForwardTag
標(biāo)簽體:bodycontent=empty
引用logic:forward
屬性 attribute:name
功能:頁面導(dǎo)向,查找配置文件的全局forward

(4) greaterEqual

類名:org.apache.struts.taglib.logic.GreaterEqualTag
標(biāo)簽體:bodycontent=JSP
引用logic:greaterEqual
屬性 attribute:cookie,header,name,parameter,property,scope,value
功能:大于等于比較符

(5)greaterThan

類名:org.apache.struts.taglib.logic.GreaterThanTag
標(biāo)簽體:bodycontent=JSP
引用logic:greaterThan
屬性 attribute:cookie,header,name,parameter,property,scope,value
功能:大于比較符

(6) iterator

類名:org.apache.struts.taglib.logic.IterateTag
標(biāo)簽體:bodycontent=JSP
引用logic:iterator
屬性 attribute:collection,id,indexId,length,name,offset,property,scope,type
功能:顯示列表為collection的值(List ,ArrayList,HashMap等)

(7)lessEqual

類名org.apache.struts.taglib.logic.LessEqualTag
標(biāo)簽體:bodycontent=JSP
logic:lessEqual
屬性 attribute:cookie,header,name,parameter,property,scope,value
功能:小于等于比較符

(8)lessThan

類名:org.apache.struts.taglib.logic.LessThanTag
標(biāo)簽體:bodycontent=JSP
logic:lessThan
屬性 attribute:cookie,header,name,parameter,property,scope,value
功能:小于比較符

(9)match

類名:org.apache.struts.taglib.logic.MatchTag
標(biāo)簽體:bodycontent=JSP
引用logic:match
屬性 attribute:cookie,header,location,name,parameter,property,scope,value
功能:比較對(duì)象

(10)messagesNotPresent

類名:org.apache.struts.taglib.logic.MessagesNotPresentTag
標(biāo)簽:bodycontent=JSP
引用logic:messagesNotPresent
屬性 attribute:name,property,message
功能:ActionMessages/ActionErrors對(duì)象是否不存在

(11)messagePresent

類名:org.apache.struts.taglib.logic.MessagesPresentTag
標(biāo)簽:bodycontent=JSP
引用logic:messagePresent
屬性 attribute:name,property,message
功能:ActionMessages/ActionErrors對(duì)象是否不存在

(12)notEmpty

類名:org.apache.struts.taglib.logic.NotEmptyTag
標(biāo)簽:bodycontent=JSP
引用logic:notEmpty
屬性 attribute:name,property,scope
功能:比較對(duì)象是否不為空

(13)notEqual

類名:org.apache.struts.taglib.logic.NotEqualTag
標(biāo)簽:bodycontent=JSP
引用logic:notEqual
屬性 attribute:cookie,header,name,parameter,property,scope,value

(14)notMatch

類名:org.apache.struts.taglib.logic.NotMatchTag
標(biāo)簽:bodycontent=JSP
引用logic:notMatch
屬性 attribute:cookie,header,location,name,parameter,property,scope,value
功能:比較對(duì)象是否不相等

(15)notPresent

類名:org.apache.struts.taglib.logic.NotPresentTag
標(biāo)簽:bodycontent=JSP
引用logic:notPresent
屬性 attribute:cookie,header,name,parameter,property,role,scope,user
功能:request對(duì)象傳遞參數(shù)是否不存在

(16)present

類名:org.apache.struts.taglib.logic.PresentTag
標(biāo)簽:bodycontent=JSP
引用logic:present
屬性 attribute:cookie,header,name,parameter,property,role,scope,user
功能:request對(duì)象傳遞參數(shù)是否存在

(17)redirect

類名:org.apache.struts.taglib.logic.RedirectTag
標(biāo)簽:bodycontent=JSP
引用logic:redirect
屬性

attribute:anchor,forward,href,name,page,paramId,paramName,paramProperty,paramScope,property,

scope,transaction
功能;頁面轉(zhuǎn)向,可傳遞參數(shù)

【編輯推薦】

  1. 在Eclipse中開發(fā)struts應(yīng)用程序
  2. 手把手教你在Eclipse中配置開發(fā)Struts
  3. Eclipse下開發(fā)struts完整解決亂碼問題
  4. Struts相關(guān)背景介紹
  5. 使用Easy Struts for Eclipse開發(fā)Struts
責(zé)任編輯:張燕妮 來源: 百度空間
相關(guān)推薦

2009-06-08 16:57:00

Struts HTML

2009-06-03 14:44:13

Struts標(biāo)簽logiciterate

2009-06-04 08:21:13

struts標(biāo)簽logic:itera

2009-06-04 09:20:19

struts2 if標(biāo)使用

2023-12-12 07:16:34

HTML標(biāo)簽開發(fā)

2009-09-22 18:26:48

2010-09-09 09:34:32

DIV

2009-06-05 10:46:12

struts logilogic標(biāo)簽

2009-07-07 11:18:59

JSP Servlet

2009-06-05 09:24:53

struts標(biāo)簽jsp

2016-10-21 10:00:01

HTML標(biāo)簽WEB

2009-06-29 15:57:54

JSP標(biāo)簽庫

2009-07-02 08:50:01

JSP標(biāo)簽庫

2010-09-13 09:35:28

DIVCSS

2020-08-16 08:59:23

HTML標(biāo)簽開發(fā)

2010-08-31 12:42:22

CSS a標(biāo)簽

2010-06-24 09:54:50

HTML 5Video標(biāo)簽

2014-03-17 09:34:01

HTMLHTML閉合

2009-08-18 13:54:41

C#標(biāo)簽

2009-07-07 17:43:33

JSP系統(tǒng)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)