freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

struts標(biāo)簽用法大全(編輯修改稿)

2024-09-26 12:14 本頁面
 

【文章內(nèi)容簡介】 :cancel 下面是對應(yīng)的 action 中的代碼: if(isCancelled(request)){ //action 被取消時要做的事情寫在這里 return (cancel)。 }else{ //action 沒有被取消時要做的事情寫在這里 return (success)。 } html:select html:select 標(biāo)簽生成一個 select 元素。是單選還是多選取決于該標(biāo)簽的 multiple 屬性。如果指定了 multiple=true則為多選,此時對應(yīng)的屬性應(yīng)該是一個數(shù)組。如果沒有指定 multiple=true則為單選,此時對應(yīng)的屬性應(yīng)該是標(biāo)量。 注意:為了正確的處理沒有做任何的選擇的情況,在 ActionForm中的 reset()方法中必須將標(biāo)量屬性設(shè)置為默認(rèn)值而將數(shù)組的長度置為 0。 另外的一個重要問題就是 struts 如何生成 option 元素了,這個任務(wù) struts 交給了 html:option、 html:options 和 html:optionsCollection 三個標(biāo)簽。 html:option 標(biāo)簽 html:option標(biāo)簽生成一個 HTML 的 option 元素。該標(biāo)簽必須嵌在 html:select 標(biāo)簽中。它的顯示文本來自其標(biāo)簽體,也可以來自于資源文件。它的 value 屬性用來指定什么值將要被提交。 html:option value=oneone/html:option html:option value=twotwo/html:option html:options 標(biāo)簽 html:options 標(biāo)簽生成 多個 HTML 的 option 元素。該標(biāo)簽必須嵌在 html:select 標(biāo)簽中。而且工作方式有些特殊,它的 name 與 property 屬性和其它標(biāo)簽的 name 與 property 屬性意義不一致,讓我們具體看一下它的工作方式。 ? 指定 collection 屬性 ? 沒有指定 collection 屬性 指定 collection 屬性 讓我通過示例來介紹在指定 collection 屬性時該標(biāo)簽的工作方式,首先要說明 selectForm中的 persons 和 listForm中的 persons 完全一致。請參見 bean:define 標(biāo)簽。 下面的代碼先利用 bean:define 標(biāo)簽將 selectForm中的 persons取到 page 作用域中,然后html:options標(biāo)簽再依據(jù) collection=personCollection選中這個 persons并將其中的每一個對象 (Person 類型 )生成一個 option 元素。該標(biāo)簽的 property=id表示 persons 中的對象 (Person 類型 )的 id 屬性將作為 option 元素的 value 值。該標(biāo)簽的 labelProperty=name表示persons 中的對象 (Person 類型 )的 name 屬性將作為 option 元素的 label 值。 當(dāng)這個 select 提交時所選擇的值將被提交到 selectForm(name=selectForm)中的 person對象 (這是在 SelectForm中聲明的一個 Person 類型的域?qū)iT用來接收提交的值 )的 id 屬性中 (property=)。 bean:define id=personCollection name=selectForm property=persons/ html:select name=selectForm property= size=1 html:options collection=personCollection property=id labelProperty=name/ /html:select 沒有指定 collection 屬性 讓我通過示例來介紹沒有指定 collection 屬性時該標(biāo)簽的工作方式,先來看看 ids 和 names的定義: private ListString ids = null。 private ListString names = null。 上面的代碼來自 SelectForm,其中 ids 是一個 String 的列表, names 也是一個 String的列表。我們暫時假定這兩個列表含有相同數(shù)目的元素。有了這些讓我們開始介紹下面的代碼。html:options 標(biāo)簽用 ids 中的第 i個值作為 option 元素的 value值同時使用 names中相同位置的值 (第 i 個值 )作為 option 元素的 label 值。如果 ids 比 names 長那么多出的 ids 中的值將即作為 option 的 value 又作為 option 的 label。如果 ids 比 names 短那么多出的 names的值會被丟掉。 當(dāng)這個 select 提交時所選擇的值將被提交到 selectForm(name=selectForm)中的 person對象 (這是在 SelectForm中聲明的一個 Person 類型的域?qū)iT用來接收提交的值 )的 id 屬性中 (property=)。 html:select name=selectForm property= size=1 html:options property=ids labelProperty=names/ /html:select html:optionsCollection 標(biāo)簽 html:optionsCollection 標(biāo)簽生成多個 HTML 的 option元素。該標(biāo)簽必須嵌在 html:select 標(biāo)簽中。它的功能和 html:options 標(biāo)簽的相同,但是它的 name 與 property 屬性和其它標(biāo)簽的 name 與 property 屬性意義一致,理解起來比較自然。 讓我通過示例來介紹 html:optionsCollection 標(biāo)簽的用法。首先依據(jù) name=selectForm和 property=persons取到 selectForm中的 persons 列表,然后將列表中的對象 (Person類型 )的 id 屬性作為 option 元素的 value 值 (value=id),將列表中的對象 (Person 類型 )的 name屬性作為 option 元素的 label 值 (label=name)。 html:select name=selectForm property= size=1 html:optionsCollection name=selectForm property=persons label=name value=id/ /html:select 下面是一個多選的示例,雖然示例中使用了 html:options 標(biāo)簽,但是 html:option 和 html:optionsCollection 也能夠用來多選。而且您還必須意識到 html:option、 html:options 和 html:optionsCollection這三個標(biāo)簽可以同時使用。代碼中的 personIds 是 SelectForm中聲明的一個 String[]類型的數(shù)組用來接收提交的多個值。 html:select name=selectForm property=personIds multiple=true size=2 html:options property=ids labelProperty=names/ /html:select html:checkbox html:check 標(biāo)簽生成一個 checkbox。這里的 value 值可以是 true, yes 或 on。如果您要提交其它的值 (如某種形式的標(biāo)識 )應(yīng)該考慮使用 html:multibox標(biāo)簽。 注意 :為了正確的處理沒有選中的 checkbox您必須在 reset()中設(shè)置對應(yīng)的屬性為 false。 下面的代碼示例了 html:checkbox標(biāo)簽的用法,其中 CheckboxForm中聲明了三個 boolean 類型的域,如下: html:checkbox name=checkboxForm property=oneOne/html:checkbox html:checkbox name=checkboxForm property=twoTwo/html:checkbox html:checkbox name=checkboxForm property=threeThree/html:checkbox 如果選中后被提交則相應(yīng)的屬性的值為 true。 html:radio html:radio 標(biāo)簽生成一個 radio。主要的用法有兩種,下面我們通過代碼來示例。 下面的代碼示例了 html:radio 標(biāo)簽的一般用法,如果被提交則選中的 radio 的 value 值將被提交到 radioForm中的 id 中。 html:radio name=radioForm property=id value=00001One/html:radio html:radio name=radioForm property=id value=00002Two/html:radio 下面的代碼示例了 html:radio 標(biāo)簽的典型用法,其中的 persons 和 bean:define 標(biāo)簽中的一致,您可以參考 bean:define標(biāo)簽。我只介紹這個 html:radio idName=person property=id value=id, idName 指定 html:radio 要使用的 bean(這里為 person), value=id表示person的 id屬性將作為 radio元素的 value 值而 property=id表示提交時選中的 radio的值將被提交給 radioForm中的 id 屬性。 logic:notEmpty name=radioForm property=persons logic:iterate id=person name=radioForm property=persons html:radio idName=person property=id value=id bean:write name=person property=name/ /html:radio /logic:iterate /logic:notEmpty html:multibox html:multibox標(biāo)簽生成多個 checkbox。當(dāng)您要使用大量的 checkbox時使用這個標(biāo)簽非常方便,可以使您避免在 ActionForm中 聲明大量的 boolean 類型的變量,帶之以一個數(shù)組就行了。 注意 :為了正確的處理沒有選中的 checkbox您必須在 reset()中設(shè)置數(shù)組的長度為 0。 下面的代碼示例了 html:multibox標(biāo)簽的一般用法,如果被提交則選中的所有 checkbox的 value 值將被提交到 multiboxForm中的 selectedItems 中,這是一個 String[]數(shù)組。 html:multibox name=multiboxForm property=selectedItems value=00001/ h
點擊復(fù)制文檔內(nèi)容
高考資料相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1